canvas.draw() + pyqt4 memory leak

Many thanks for the fix. I applied the changes and now I can run the program.
The numbers go up with every canvas draw(). I attached a screenshot with the program you sent (the mpl example) running. The screenshot shows how the memory goes up and up unbounded with every canvas draw(). It would appear then that it leaks memory in some platforms (ie.windows) but others are OK.
I would be OK if I knew how to release the memory back every now and then (maybe every 100 canvas draw()), but I have not been successful to do so.
Cheers

pyqt4.png

···

— On Thu, 6/16/11, Eric Firing <efiring@…202…> wrote:

From: Eric Firing <efiring@…202…>
Subject: Re: [Matplotlib-users] canvas.draw() + pyqt4 memory leak
To:
matplotlib-users@lists.sourceforge.net
Date: Thursday, June 16, 2011, 1:42 PM

On 06/16/2011 04:31 AM, zb wrote:

line 1245 of cbook.py is missing the windows platform. So windows cannot
be tested.

In the development version of mpl it can (I added it–but too recently
for it to have gotten into 1.0.1), provided you have the “tasklist”
executable, which I think is a free download from Microsoft.

If you would like to try it, you could include the new version, below,
in your test script.

Eric

def report_memory(i=0): # argument may go away
‘return the memory consumed by process’
from subprocess import Popen, PIPE
pid = os.getpid()
if sys.platform==‘sunos5’:
a2 = Popen(‘ps -p %d -o osz’ % pid,
shell=True,
stdout=PIPE).stdout.readlines()
mem = int(a2[-1].strip())
elif sys.platform.startswith(‘linux’):
a2 = Popen(‘ps -p %d -o rss,sz’ % pid, shell=True,
stdout=PIPE).stdout.readlines()
mem = int(a2[1].split()[1])
elif sys.platform.startswith(‘darwin’):
a2 = Popen(‘ps -p %d -o rss,vsz’ % pid, shell=True,
stdout=PIPE).stdout.readlines()
mem = int(a2[1].split()[0])
elif sys.platform.startswith(‘win’):
try:

a2 = Popen([“tasklist”, “/nh”, “/fi”, “pid eq %d” % pid],
stdout=PIPE).stdout.read()
except OSError:
raise NotImplementedError(
"report_memory works on Windows only if "
“the ‘tasklist’ program is found”)
mem = int(a2.strip().split()[-2].replace(‘,’,‘’))
else:
raise NotImplementedError(
“We don’t have a memory monitor for %s” % sys.platform)
return
mem


EditLive Enterprise is the world’s most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev


Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Hi

I updated to the latest Qt and PyQt and the memory leak is not there any more. Looks like matplotlib was OK.

Qt 4.7.3

PyQt 4.8.4

Windows OS

Cheers

···

From: zb <zauborg@…9…>
To: Eric Firing <efiring@…202…>; matplotlib-users@…1544…ceforge.net
Sent: Thursday, June
16, 2011 2:20 PM
Subject: Re: [Matplotlib-users] canvas.draw() + pyqt4 memory leak

Many thanks for the fix. I applied the changes and now I can run the program.
The numbers go up with every canvas draw(). I attached a screenshot with the program you sent (the mpl example) running. The screenshot shows how the memory goes up and up unbounded with every canvas draw(). It would appear then that it leaks memory in some platforms (ie.windows) but others are OK.
I would be OK if I knew how to release the memory back every now and then (maybe every 100 canvas draw()), but I have not been successful to do so.
Cheers
— On Thu, 6/16/11, Eric Firing <efiring@…202…> wrote:

From: Eric Firing <efiring@…202…>
Subject: Re: [Matplotlib-users] canvas.draw() + pyqt4 memory leak
To:
matplotlib-users@lists.sourceforge.net
Date: Thursday, June 16, 2011, 1:42 PM

On 06/16/2011 04:31 AM, zb wrote:

line 1245 of cbook.py is missing the windows platform. So windows cannot
be tested.

In the development version of mpl it can (I added it–but too recently
for it to have gotten into 1.0.1), provided you have the “tasklist”
executable, which I think is a free download from Microsoft.

If you would like to try it, you could include the new version, below,
in your test script.

Eric

def report_memory(i=0): # argument may go away
‘return the memory consumed by process’
from subprocess import Popen, PIPE
pid = os.getpid()
if sys.platform==‘sunos5’:
a2 = Popen(‘ps -p %d -o osz’ % pid,
shell=True,
stdout=PIPE).stdout.readlines()
mem = int(a2[-1].strip())
elif sys.platform.startswith(‘linux’):
a2 = Popen(‘ps -p %d -o rss,sz’ % pid, shell=True,
stdout=PIPE).stdout.readlines()
mem = int(a2[1].split()[1])
elif sys.platform.startswith(‘darwin’):
a2 = Popen(‘ps -p %d -o rss,vsz’ % pid, shell=True,
stdout=PIPE).stdout.readlines()
mem = int(a2[1].split()[0])
elif sys.platform.startswith(‘win’):
try:

a2 = Popen([“tasklist”, “/nh”, “/fi”, “pid eq %d” % pid],
stdout=PIPE).stdout.read()
except OSError:
raise NotImplementedError(
"report_memory works on Windows only if "
“the ‘tasklist’ program is found”)
mem = int(a2.strip().split()[-2].replace(‘,’,‘’))
else:
raise NotImplementedError(
“We don’t have a memory monitor for %s” % sys.platform)
return
mem


EditLive Enterprise is the world’s most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev


Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


EditLive Enterprise is the world’s most technically advanced content
authoring
tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev


Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users