On Dec 15, 2009, at 1:09 PM, Gerd Wellenreuther wrote: > > > Perry Greenfield schrieb: >> if the above code is in a loop, and there is no figure clearing in >> the loop, then >> >> rotated_images[i] = [] >> gc.collect(2) >> >> will have no effect since matplotlib will still have references to >> the array (and generally, you never need to call gc.collect by the >> way). > I do / did not know whether matplotlib is actually refering to my > array (in that context dereferencing it will not free memory), or > actually copying the data at one instance (in that case it should > help). So, as you can see I am lacking the inside-knowledge of > matplotlib, and was just trying some things which were not doing any > harm (at least this is what I suppose). > To give an idea, when you ask matplotlib to render an image, it processes it (resamples, rescales, maps to colors, etc) in order to actually display it. Since it may redo all that if you resize or otherwise re-render the figure, it needs to keep a reference to the original image. Even if you delete your reference to it, it still has it, and thus it won't be deleted until the figure is cleared. So if the input to the imshow call is the full size array, you will have that around. You may want to downsample that image to lower resolution (and make sure that the downsampled version is a copy, not a view of the original array). Then you can get rid of the original image, and instead display the smaller version. Keeping that around won't impact memory.
> But I would expect that figure clearing would not only free memory, > but also erase the formerly inserted images, right? *That* would > harm ;). Yes, it would erase it :-) Perry ------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users