Memory Not Released - PyQt4

It can be bindings (SIP) or even python, but I have a problem with Qt (pyqt4).

I have a QTabWidget, and inside it I put widgets that can be closed.

I have a widget that allocates about 400 MB of memory. I did not set the parent, and I call deleteLater()on close, but nothing happens. Even a python gc call does not work:

import gc
gc.collect ()

Now when you close a widget from QTabWidget without using deleteLater(), more and more memory is allocated. So let's say that I open 4 tabs of a large-scale memory widget, I use about 1.6 GB of memory. If I close them all and open a new one, I now use up to 2 GB of memory.

If I use deleteLater(), after closing 4 tabs, I do not go up to 2 GB, opening a new one, then I need to open 5 tabs. But, and here is the problem, 1.6 GB is still allocated for the process (python), even if all the widgets are closed and has been called deleteLater.

thank

+3
source share
1 answer

I had this - somewhere you have a link to your widget, and that link was counted ... the only way to remove this widget is to make sure there are no remaining links so that python can collect it.

At least you don't have dangling links like C ++, which can lead to some unpleasant crashes ...


: ,

+3

All Articles