PyQt Ram Usage

C

Country Boy

Hi,
I am new to Python (and programming so pardon my ignorance)
I have a small PyQt program that lives in windows system tray. I am
using Suds & ElemetTree to do webservices call and parse XML.
I have a QTimer that runs every 30 seconds and fetches the updated
data from the server.
Finally, the python script is "frozen" into exe using CX_FREEZE.
When I run the exe, it starts with 18MB (which i think i high for an
app that just fetches info from webserver and creates a menu full of
web url shortcuts, but thats besides the point).
After every 30 seconds (as my QTimer timeout()), my RAM usage goes up
by 400KB. So after an hour or two of running the application almost
uses ~60MB or more, which is ridiculous.
I think my application has some memory leaks and I think every time I
create an instance of the WebService class (its a QThread that fetches
information using WSDL) the RAM goes up but doesn't get released once
Class's work is done. Can somebody pls direct me into the things that
I should be looking into to troubleshooting this issue...


I am running my application on Windows Embedded thin clients so its
really important that my application's memory footprint is low.

Update: I tried del <objectname> and it decreased the amount of RAM
overall, but the application still starts with 20MB and then goes unto
40MB.
 
D

David Boddie

I am new to Python (and programming so pardon my ignorance)
I have a small PyQt program that lives in windows system tray. I am
using Suds & ElemetTree to do webservices call and parse XML.
I have a QTimer that runs every 30 seconds and fetches the updated
data from the server.
Finally, the python script is "frozen" into exe using CX_FREEZE.
When I run the exe, it starts with 18MB (which i think i high for an
app that just fetches info from webserver and creates a menu full of
web url shortcuts, but thats besides the point).

It's the price you pay for features. There are ways to cut out features
you don't want if you're prepared to use a specialised version of Qt.
After every 30 seconds (as my QTimer timeout()), my RAM usage goes up
by 400KB. So after an hour or two of running the application almost
uses ~60MB or more, which is ridiculous.
I think my application has some memory leaks and I think every time I
create an instance of the WebService class (its a QThread that fetches
information using WSDL) the RAM goes up but doesn't get released once
Class's work is done. Can somebody pls direct me into the things that
I should be looking into to troubleshooting this issue...

Qt has its own way of managing memory that usually plays well with Python's
own memory management, but there are ways to accidentally create objects
that will stay alive until the application exits. In particular, beware of
creating objects with a parent QObject if you really want to manage them
from Python because Qt will keep the underlying C++ object around, even if
you delete the object in Python.

This might not be the reason for the memory usage you see, but it's one
thing to look at.

You might also need to show us some code if the problem turns out to be
more complicated than this.

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top