[PyKDE] Memory leak in QFileDialog?

Phil Thompson phil at riverbankcomputing.co.uk
Sat Apr 10 21:03:00 BST 2004


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.

Phil




More information about the PyQt mailing list