Details
-
Bug
-
Resolution: Done
-
Not Evaluated
-
None
-
6.5.3, 6.6.1
-
None
-
python 3.8 and 3.11 tested.
Description
Trying to remove an item from a QTreeWidget, either using QTreeWidget.getInvisibleRoot().removeItem(top_item) or QTreeWidget.takeTopLevelItem(index) seems to hold the memory. (Note: This issue is not there in a custom build of Qt/PySide 6.3.2)
However using QTreeWidget.clear() properly releases the memory. Please keep in mind that I would like to keep other top items.
For now I use a workaround to release the memory: During the removal, I take the top item from my main tree, spawn a dummy tree, attach the top item I want to free to the dummy tree then use the clear() method of this dummy tree. This way the memory hold by the top item is freed somehow.
I attached a demo script. Running the test creates a 1st top item that I want to keep, then will iterate several times to create and immediately remove a second top item. Those top items are always populated with 3 levels of children so that the memory footprint appears. The memory is never released.
A checkbox is provided to activate or not the workaround.
I also put some pympler prints to show the memory consumption before/after the run.