Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Garbage collection with QT

Thread Tools

Garbage collection with QT

Marco Bartel
Posts: n/a
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?

Reply With Quote
Mike Tammerman
Posts: n/a
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

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


Reply With Quote
Ken Godee
Posts: n/a
> 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


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:


if vlogin.result() == 0:
del vlogin

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Collection problems (create Collection object, add data to collection, bind collection to datagrid) Řyvind Isaksen ASP .Net 1 05-18-2007 09:24 AM
Templates - Garbage In Garbage Not Out C++ 1 07-25-2005 04:48 PM
Garbage Collection kamran MCSD 1 04-04-2005 10:04 PM
Garbage Collection and Manage Code? Laser Lu ASP .Net 5 01-27-2004 03:48 AM
Debbugging help! (.NET 1.1 Framework Garbage Collection Problems) Cheung, Jeffrey Jing-Yen ASP .Net 3 07-10-2003 07:29 PM