[PyQt] Reduce memory footprint

Jonathan Harper jon at white-walls.net
Thu Dec 23 18:22:15 GMT 2010

>I've written a small tool with a quite simple GUI using pyqt. After startup

>is completed the gui takes up 35mb memory, is there any way to reduce this
>footprint? Seems unneccesarily large.
Yes and no, but mostly no. There's a few overhead reducing features of
Python (__slots__) that will make some small amount of difference but aren't
worth the trouble. You could also be all picky-like and only import the
modules in QtCore and QtGui you absolutely need.

In the grand scheme of things, however, you're not going to crunch that 35mb
into 5mb or so. Reason one is that you're using Python, so the interpreter
is running along with its overhead. Reason two is that you're using Qt for
the GUI, so those shared libraries have to be loaded. Any blood sweat and
tears you expend to reduce your application's footprint is peanuts for a
small app.

-- Jon Harper

More information about the PyQt mailing list