[Qgis-user] reduce number of open files in pyqgis script

Martin Landa landa.martin at gmail.com
Fri Dec 26 08:50:02 PST 2025


Dear Greg,

pá 26. 12. 2025 v 16:48 odesílatel Greg Troxel via QGIS-User <
qgis-user at lists.osgeo.org> napsal:

> I would suggest reading the gdal code to try to understand this.
>

First of all, thanks for the quick answer! I wonder which gdal code do you
mean?


> Looking at your code above, I wonder if the layer returned by clip_layer
> holds a reference to the first argument.  (This should be easy to
> understand from code reading).
>

If I replace the clip_layer() function with calling `extractbyextent` from
processing, the result is the same. Number of open files is increasing. It
seems to me that files open by QgsVectorMapLayer constructors are not
closed properly even when releasing memory via `del`...

Best regards, Martin

-- 
Martin Landa
https://geomatics.fsv.cvut.cz/en/employees/martin-landa/
https://gismentors.cz/mentors/landa
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20251226/f88e69da/attachment.htm>


More information about the QGIS-User mailing list