Hello, Benjamin,
Thanks for your quick response ! I found that I only need use clf(), and
then everything is fine ! The code can be run quickly and I can exit ipython
gracefully afterwards. So it is not a problem of backend, just of clearing the
existing figures properly ! (close() is not good because the figures are not
displayed.)
cheers,
xiaoni
________________________________
From: Benjamin Root <ben.r...@ou.edu>
To: xiaoni <wang...@yahoo.com>
Cc: matplotlib-users@lists.sourceforge.net
Sent: Tue, August 24, 2010 2:29:32 AM
Subject: Re: [Matplotlib-users] a question about backend, matplotlib and ipython
On Mon, Aug 23, 2010 at 1:53 PM, xiaoni <wang...@yahoo.com> wrote:
Hello,
> I got a problem with backend in matplotlib.
> I used ipython for launching the codes and the backend of
>matplotlib is GTKAgg. I have a code.py with a for loop for processing data,
>and in each iteration I read and plot and save the figures. Because
>there are so many figures, I set the non-interative mode and not
>using
>"show()" in the code. Then the memory is used more and more as the
>iteration number increases, and the most memory is due to write_png
>function. I guess that the figures (though not shown on the screen)
>from each iteration take the memory, and try to close the figures produced at
>each iteration.
>what I did:
>modify the backend to Agg in the code
>add "close('all')" before each iteration finish.
>
> This works for removing the memory problem. But a new issue
> arrive.
>After the run is finished, the ipython command window has no
>response
>to any keyboard input for a few seconds, then a warning message appear:
> "Warning: Timeout for mainloop thread exceeded switching to
>nonthreaded mode (until mainloop wakes up again)",
>and when I tried to quit ipython afterwards, it is stuck there and
>the
>ipython is crashed.
> But if I tried using "python code.py" , then it works well : no warnings.
> Does it mean that we can not use ipython and a backend non-GUI at the same
>time ?
>
> Any one would like to explain a bit ? Thanks in advance !!
>
>
>xiaoni
>
>
xiaoni,
For the way that you appear to be using ipython, it might be better to just use
regular python instead. ipython is very useful for interactive systems and
other advanced topics, but for a simple, loop-driven image generator, python
will work just fine.
As for your memory usage, doing a clf() should be helpful to keep it under
control. I should also note that ipython have been known to cause memory use
to
grow due to the extra references it holds to the figure data, although I don't
know if this is still true in the latest version that is currently being worked
on.
I hope this helps,
Ben Root
------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users
worldwide. Take advantage of special opportunities to increase revenue and
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users