-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leak with attributes (#25881) #32944
Comments
can you explain what you are trying to accomplish? |
In the c++ docs you can find for attributes() a note, that you also could accomplish the same when you use the way from my bug report. https://qgis.org/api/classQgsFeature.html#a5a473f89868c234d53cea67504cd2f2e But that way is leaking huge amount of memory for me... |
And if you do ? for feat in layer.getFeatures():
feat.attributes() |
|
And if you try for feat in layer.getFeatures():
[ attr for attr in feat] As stated in the doc? |
Memory leak |
It might be the list comprehension and your dataset that causes leakage. |
The leak is also present when using the normal for loop way. |
Same behavior with 3.12.0 |
Steps for reproduction ...
>>>layer = QgsVectorLayer(r"PATH\altlpar0.dbf", "", "ogr")
>>>for _ in range(1000):
... for feat in layer.getFeatures():
... t = [attr for attr in feat]
... # let the gc cleanup t (no difference)
... # del t |
Tested it with 3.16.3 again and it still has the same memory leaking effect |
The python docs also says that this way of doing it is possible: https://qgis.org/pyqgis/master/core/QgsFeature.html?highlight=qgsfeature#qgis.core.QgsFeature.attributes (in the note section) while being at it again, i tried some things and documented it with screenshots, showing that qgis is even holding onto the leaked memory: |
There is the possibility that the creation of an iterator in python is the issue, though this may come from sip as this process is not present in c++ and only built in python
|
I can't reproduce on current versions, is this still an issue? |
Tried it with Leaks: layer = QgsVectorLayer(r"PATH\altlpar0.dbf", "", "ogr")
for _ in range(1000):
for feat in layer.getFeatures():
t = [attr for attr in feat] The version below results in a memory usage of 286 MB, with no memory spikes at all. No Leak: layer = QgsVectorLayer(r"PATH\altlpar0.dbf", "", "ogr")
for _ in range(1000):
for feat in layer.getFeatures():
t = [attr for attr in feat.attributes()] |
Describe the bug
#25881
same area, but with different approach ...
In the docs you can find this approach for getting all attributes:
[attr for attr in feature]
, so i did that and after a few seconds my memory was completely full.When using attributes() it works fine.
How to Reproduce
Use a large dataset with NULL attributes
QGIS and OS versions
3.10.0
The text was updated successfully, but these errors were encountered: