[PyKDE] Constantly increasing memory usage in (some) PyQt applications

Phil Thompson phil at riverbankcomputing.co.uk
Fri Jan 14 13:56:24 GMT 2005


> Hello,
>
> I've been using PyQt for about six months. IMHO, PyQt is *great*, a
> perfect
> tool for creating first-class portable GUI applications. It is also very
> enjoyable to work with Python and Qt, both are elegant and nicely
> designed.
>
> However, I've some issues about the memory usage of PyQt applications,
> both
> the ones that I wrote and that I use. As an example I've examined the
> memory
> usage of Eric with K System Guard:
>
>                       VmSize    VmRss
> Initial                49056    35168
> Open Settings Window   51116    37884
> Close & Open Again     52564    39440
> Close & Open Again     54080    40952
> Close & Open Again     55724    42588
> Close & Open Again     57280    44088
> Close & Open Again     58728    45588
>
> Both VmSize and VmRss values are constantly increasing. For the test, I
> started Eric3, then repeatedly clicked Settings -> Preferences and close
> preferences dialog.
>
> I observe similar memory usage patterns on my own code. As the complexity
> of
> my dialogs/widgets increase, I see more of incresing memory usage.
>
> I tried to track down possible leakages on my code by using gc module,
> specially gc.get_objects() in Python level. But I still observe increased
> memory usage even if gc.get_objects() seems to stay constant.
>
> I googled and searched various lists about Python, as far as I understand,
> Python never releases allocated memory back to the OS, and some objects
> like
> integers and floats are basically immortal. So it is normal to observe an
> "always increasing memory usage" pattern because memory is never released
> back. However, once the objects are garbage collected, released memory is
> available to be used by new objects. So, for a simple situation like
> opening
> and closing a dialog, I think the memory usage should remain constant at
> *some* point.
>
> Is this behaviour normal? Can it harm long-running GUI processes?
>
> Best regards,
> Umit OZTOSUN
>
> System Information:
> Intel P4 2.5 GHz, 512 MB RAM
> Debian Testing, Python 2.3.4, Qt 3.3.3, PyQt 3.12, SIP 4.0.1, Eric 3.5.0

The current SIP v4 snapshot contains a fix for a memory leak, however it
(SIP, not the fix) causes eric problems at the moment. If you can produce
a small example that appears to demonstrate a leak then I'll look at it.

Phil




More information about the PyQt mailing list