Garbage collection with QT

M

Marco Bartel

Hello,
I got a question regarding garbage collection in python when using PyQT.
How can i safely get rid of an Object instance and delete it
permanently. For example when having a QTable with a bunch of records
inside and closing the window hosting it, the memory space will not
being freed up and when opening it again, the memory usage will grow.
This ends up, when opening and closing the window serval times, in
having all swapspace occupied and OS crashing.

Is there a way, to find out all references to the QMainWindow or its
hosted QTable, for having a mechanism to destroy them?

THX
Marco
 
M

Mike Tammerman

Not all leakage problems caused by qt or python. There is a wrapping
layer between Qt and Python provided by SIP. Therefore, SIP may cause
leakages. Also PyQt had a paintCell memory leakage problem several
months ago. If you're using an old snapshot of PyQt or SIP, that would
be a problem. Try using the latest snapshots. Also mention your
versions and problems to the PyKDE mailinglist, it could be more
helpful.

If you want to delete C++ objects in Qt, consider using
QObject.deleteLater() method. IMHO, this won't help.

Mike
 
K

Ken Godee

Is there a way, to find out all references to the QMainWindow or its
hosted QTable, for having a mechanism to destroy them?
Yes, of coarse, the docs are your friend :)

QObject::children()
QObject::removeChild()
QObject::parent()

To find all the children for an instance you
can create a loop.

An example of a dialog window function
that cleans it self up ....

================================================
def xdialog(self,vparent,info):

vlogin = dialogwindow(parent=vparent,modal=1)

while 1:

vlogin.exec_loop()

if vlogin.result() == 0:
vparent.removeChild(vlogin)
del vlogin
break
================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top