I have a Python script that processes several country sized OpenStreetMap PBF files at a time. The problem I'm having is that: each time I open and process one of these files, I lose anywhere from 200MB to a gig of hard drive space (I'm assuming to some temp storage directory somewhere).
When I process loads of these files, I eventually end up running out of disk space and the script crashes. I've tried several ways to get the script to unload the
QgsVectorLayer object that I'm processing in an attempt to reclaim some disk space. These include:
- Placing the loading & processing of the individual layers into a separate method that (I assumed) would be automatically removed once the method returns.
- Explicitly calling
delon the layer object.
QgsProject.instance().removeMapLayeron the layer in the hope to get it removed some how.
Unfortunately, none of these worked, so far the only thing that seems to unload the layers and delete the temporary files is allowing the script to complete fully.
Is there a way for me to ensure that, once I'm done with a
QgsVectorLayer, I can close it, and have it clean up its temp data?