[PyQt] Hunting down memory leaks

Darryl Wallace darryl.wallace at prosensus.ca
Tue Dec 14 16:05:42 GMT 2010

> -----Original Message-----
> From: pyqt-bounces at riverbankcomputing.com [mailto:pyqt-
> bounces at riverbankcomputing.com] On Behalf Of Mikael Modin
> Sent: December-13-10 5:50 AM
> To: pyqt at riverbankcomputing.com
> Subject: [PyQt] Hunting down memory leaks
> Hi,
> I'm currently developing a little tool and it seems I have a memory
> leak somewhere along the line that handles images, so each leak is
> around 7mb which is kind of a big deal leading my app quickly to
> 100mb. I'm wondering if any of you havea any tips to figure out what
> kind of object I'm leaking and where I'm leaking them. I'm new to
> python, Qt and PyQt so I'm not very well versed in what tools are
> available.
> Kind regards
> Mikael

One of the things I've found in this regard has to do with Python and
garbage collection.  If the reference count to certain objects does not go
to zero then the item will not be garbage collected.

Ensure that the objects that you want cleaned up have no references to
them.  I've found that setting widgets' parents to None and then setting
that variable to None often does the trick.

Anyone else have tips on garbage collection with PyQt???


More information about the PyQt mailing list