From: John H. <jdh...@ac...> - 2006-12-29 14:44:31
|
>>>>> "Eric" == Eric Emsellem <ems...@ob...> writes: Eric> Questions and problems: 1/ when I load the image the first Eric> time (first imshow command in the script), I see that, Eric> although the amount of data is very small, Eric> ipython/matplotlib already uses more than 40 Mb of memory! Eric> Is that normal? It seems high, but looks inline with the size of the mpl extension code (though some of which is redunant numpy/numeric/numarray extensions that shouldn't all be loaded) peds-pc311:~/mpl/build> du -h 20M ./lib.linux-i686-2.4/matplotlib/backends 8.0K ./lib.linux-i686-2.4/matplotlib/toolkits 8.0K ./lib.linux-i686-2.4/matplotlib/numerix/mlab 8.0K ./lib.linux-i686-2.4/matplotlib/numerix/ma 8.0K ./lib.linux-i686-2.4/matplotlib/numerix/linear_algebra 8.0K ./lib.linux-i686-2.4/matplotlib/numerix/random_array 8.0K ./lib.linux-i686-2.4/matplotlib/numerix/fft 64K ./lib.linux-i686-2.4/matplotlib/numerix 40K ./lib.linux-i686-2.4/matplotlib/enthought/traits/ui/null 252K ./lib.linux-i686-2.4/matplotlib/enthought/traits/ui 632K ./lib.linux-i686-2.4/matplotlib/enthought/traits 28K ./lib.linux-i686-2.4/matplotlib/enthought/resource 12K ./lib.linux-i686-2.4/matplotlib/enthought/util 676K ./lib.linux-i686-2.4/matplotlib/enthought 40M ./lib.linux-i686-2.4/matplotlib 40M ./lib.linux-i686-2.4 40M Eric> 2/ When I now use the mouse_move event, it can go up to 150 Eric> Mb of memory usage!! Again: is that normal? In your example code below, I notice you are drawing on every mouse motion. I believe there is a Tkinter specific leak in TkAgg if memory serves, but it's outside of mpl. What backend are you using? Does the problem go away with a different backend? If there is a leak under our control we will certainly find it an fix it to the best of our abilities. Our canonical memory leak checking script (which does an imshow and more) is running rock solid on the Agg backend so if there is a leak it is probably backend specific. I noticed in your example script that you are only modifiying a text entry on mouse motion. Your performance will dramatically improve if you use the blitting techniques described in the animation tutorial. The basic idea is to capture the background as a pixel buffer, identify the rectangle region you want to draw the text into, draw the background, update the text, redraw only the text rectangle etc.... See http://www.scipy.org/Cookbook/Matplotlib/Animations After you've read through this if you get stuck let me know and I'll put together a small demo for you. JDH |