[PyKDE] Memory leak in QFileDialog?

Tuvi, Selim stuvi at slac.stanford.edu
Mon Apr 12 22:01:01 BST 2004

Thanks. Calling deleteLater() on the object after usage took care of the problem.

It never occurred to me to look at the web site FAQ, it may be worthwhile to add them to the PyQt documentation.


Selim Tuvi, Research Engineering Group, SLAC
GLAST, I&T Online, MS 98
Tel:650-926-3376 Fax:650-926-4335

-----Original Message-----
From: Phil Thompson [mailto:phil at riverbankcomputing.co.uk] 
Sent: Saturday, April 10, 2004 12:00 PM
To: pykde at mats.imk.fraunhofer.de
Cc: Tuvi, Selim
Subject: Re: [PyKDE] Memory leak in QFileDialog?

On Saturday 10 April 2004 4:28 am, Tuvi, Selim wrote:
> I am experiencing memory leak like behavior when I use the instantiation
> method of opening a file with QFileDialog under Windows XP.
> Attached is a modified version of the application.py script. If I click on
> "Open File" toolbar icon and escape out about 8 times then the task manager
> memory usage increases by about 1Kbytes.
> I tried deleting the object after usage but that didn't change the outcome.
> If I go back to using QFileDialog.getOpenFileName instead then I don't
> observe the memory increase.
> I ran one of the Qt C++ examples that use it in a similar fashion and I
> don't see the memory leak there. The example is:
> C:\qt\3.3.1\examples\network\networkprotocol
> Unfortunately I can not use the getOpenFileName way in my application since
> I am adding custom widgets to the file dialog window.
> I am using SIP4 (snapshot-20040317), PyQt 3.11, Qt 3.3.1.

I think it's just the usual issue with deleting the children of a QObject. You 
are creating the dialog as a child of the main window - and therefore 
transferring ownership of it from Python to C++.

In order to delete it then you need to transfer ownership back the other way - 
see the FAQ. Or you could re-use the dialog each time rather than creating a 
new one each time.


More information about the PyQt mailing list