Possible workaround for memory leak using pylab.figure(), pylab.show() ?

Hi,

I have already submitted this issue as a possible problem to Tracker, however there is no response till now http://sourceforge.net/tracker/?func=detail&aid=2940967&group_id=80706&atid=560720. Probably, someone could help me with possible workaround for this problem.

I use the pylab.figure in the other application where a user should close the figure manually. After the figure is closed, I would expect the memory goes back to the level it was before. However, it is not the case, I have noticed a memory leak when using pylab.figure(), pylab.show().If I try to let show figure via pylan.ion(), then pylab.figure() and pylab.iof(), I also see the memory leak.

Below is simple example:

pylab.ion()

for i in range(10):

pylab.figure()

pylab.draw()

val = cbook.report_memory(i)

print i, val

pylab.ioff()

the same loop is used for show():

for i in range(10):

pylab.figure()

pylab.plot([1,3])

val = cbook.report_memory(i)

print i, val

pylab.show()

I use the python version 2.5.1, the matplotlib version 0.99.0, OS: SunOs5 (Solaris), backend: TkAgg.

Thanks in advance,

Tanja

Have you tried the pylab.close() this should force the flush of the memory.

2010/2/1 Tanja Gurzhiy <tanja.gurzhiy@…287…>

···

Hi,

I have already submitted this issue as a possible problem to Tracker, however there is no response till now http://sourceforge.net/tracker/?func=detail&aid=2940967&group_id=80706&atid=560720. Probably, someone could help me with possible workaround for this problem.

I use the pylab.figure in the other application where a user should close the figure manually. After the figure is closed, I would expect the memory goes back to the level it was before. However, it is not the case, I have noticed a memory leak when using pylab.figure(), pylab.show().If I try to let show figure via pylan.ion(), then pylab.figure() and pylab.iof(), I also see the memory leak.

Below is simple example:

pylab.ion()

for i in range(10):

pylab.figure()
pylab.draw()
val = cbook.report_memory(i)
print i, val

pylab.ioff()

the same loop is used for show():

for i in range(10):

pylab.figure()
pylab.plot([1,3])
val = cbook.report_memory(i)
print i, val

pylab.show()

I use the python version 2.5.1, the matplotlib version 0.99.0, OS: SunOs5 (Solaris), backend: TkAgg.

Thanks in advance,

Tanja


The Planet: dedicated and managed hosting, cloud storage, colocation

Stay online with enterprise data centers and the best network in the business

Choose flexible plans and management services without long-term contracts

Personal 24x7 support from experience hosting pros just a phone call away.

http://p.sf.net/sfu/theplanet-com


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Hi

thanks for the answers, but I do not think it is applicable in this situation.
In the application I have an event that triggered (e.g., a button is pressed) the opening of the window by pylab.figure() and then the application shows (via figure pylab.show()) it to the user. So, the user defines when the figure will be closed. So, if I use pylab.close(1) in the application, I cannot use pylab.show() afterwards in the code (because it will be nothing to show…)

The only way I found to ‘flush’ the memory is via bind() based on the ‘master’ (e.g., master = Tkinter.Tk(), master.bind(’’, self.close_showed_figures()) but it is already late for the application because the memory leak is only of concern when ‘master’ does not destroyed.

Kind regards,
Tanja

···

On Mon, Feb 1, 2010 at 3:33 PM, Bruno Santos <bacmsantos@…1003…7…> wrote:

Have you tried the pylab.close() this should force the flush of the memory.

2010/2/1 Tanja Gurzhiy <tanja.gurzhiy@…83…287…>

Hi,

I have already submitted this issue as a possible problem to Tracker, however there is no response till now http://sourceforge.net/tracker/?func=detail&aid=2940967&group_id=80706&atid=560720. Probably, someone could help me with possible workaround for this problem.

I use the pylab.figure in the other application where a user should close the figure manually. After the figure is closed, I would expect the memory goes back to the level it was before. However, it is not the case, I have noticed a memory leak when using pylab.figure(), pylab.show().If I try to let show figure via pylan.ion(), then pylab.figure() and pylab.iof(), I also see the memory leak.

Below is simple example:

pylab.ion()

for i in range(10):

pylab.figure()
pylab.draw()
val = cbook.report_memory(i)
print i, val

pylab.ioff()

the same loop is used for show():

for i in range(10):

pylab.figure()
pylab.plot([1,3])
val = cbook.report_memory(i)
print i, val

pylab.show()

I use the python version 2.5.1, the matplotlib version 0.99.0, OS: SunOs5 (Solaris), backend: TkAgg.

Thanks in advance,

Tanja


The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business

Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com


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