[SciPy-dev] plt zooming is a memory hog

Jochen Küpper jochen at jochen-kuepper.de
Sat Nov 10 00:41:41 EST 2001


Ok, I looked at the problems reported by Eric regarding zooming into
images, leading to crashes regularly. 
(here: Linux 2.4, wxPython 2.3.1, 128MB RAM, 512MB swap)

I could not reproduce any lockups or crashes (as reported by
Eric). The image is always drawn fine after *some* time, unless I
killed the app because I am tired of waiting after a few minutes!

The reason why it took so long? Making the shown part of the image
small enough (the number of "zooms" doesn't matter, just the size of
the selected part), the python process and the Xserver grow to >600 MB
together... (v.s.)

Well the problem is here:
,----[plot_objects.py:956--963]
|     def draw(self,dc):
|         sz = array((self.the_image.GetWidth(),self.the_image.GetHeight()))
|         sz = sz * abs(self.scale)
|         sz = sz.astype(Int)
|         scaled_image = self.the_image.Scale(abs(sz[0]), abs(sz[1]))
|         bitmap = wxBitmap(scaled_image)
|         dc.DrawBitmap(bitmap, self.origin[0]+1, 
|                       self.origin[1]-scaled_image.GetHeight()+1, wx.false)
`----
A wxImage and a wxBitmap of the whole image at the needed resolution
is made. These are huge bitmaps if you zoom in a bit, I assume:((

I have no good quick way on how to handle this, but somehow this
image_object needs to know which part of itself we are interested in
and only draw that...

Greetings,
Jochen

PS: Since changes are still not in cvs and I couldn't find all patches
flying around, I attach the version of plt I used. This is a diff
against current cvs.

PPS: Eric, what's about Linus rule "release early, release often"?
It's up to you guys, but I would suggest you release snapshots as
often as you encounter an overall reasonably stable source tree, and
put changes in cvs as soon as they are there? Or something like
that. At least I am tired of sending patches between different
machines I am using. I have actually considered setting up my own
(private) cvs tree for scipy, but that is not really what I want.
-- 
Einigkeit und Recht und Freiheit                http://www.Jochen-Kuepper.de
    Liberté, Égalité, Fraternité                GnuPG key: 44BCCD8E
        Sex, drugs and rock-n-roll
-------------- next part --------------
2001-11-10  Jochen Küpper  <jochen at jochen-kuepper.de>

	* plot_objects.py (image_object.draw): Use wxBitmap constructor instead
	of deprecated ConvertToBitmap() method.

2001-10-27  Jochen Küpper  <jochen at jochen-kuepper.de>

	* wxplt.py: Reorganized file structure: plot_canvas, plot_window,
	plot_frame, global stuff.
	(plot_frame): Obey naming guidelines.
	(plot_frame.file_close): Added File->Close menu functionality.
	(plot_canvas): Add __type_hack__. Obey naming guidelines.
	(plot_canvas.__init__, on_mouse_event, on_double_click, on_paint,
	on_right_down): Add mouse event handlers, rename existing ones according
	to guidelines.
	(plot_canvas.zoom, rubberband): Implemented.
	(plot_window): Added. Provides a wxWindow with plot_canvas
	functionality.

	* interface.py (figure): Add possibility to add an externally created
	plot_canvas. Depends on plot_canvas.__type_hack__.

	* Local Variables:
	* mode: auto-fill
	* fill-column: 79
	* End:

2001-10-27  Jochen Küpper  <jochen at jochen-kuepper.de>

	* wxplt.py: Reorganized file structure: plot_canvas, plot_window,
	plot_frame, global stuff.
	(plot_frame): Obey naming guidelines.
	(plot_frame.file_close): Added File->Close menu functionality.
	(plot_canvas): Add __type_hack__. Obey naming guidelines.
	(plot_canvas.__init__, on_mouse_event, on_double_click, on_paint,
	on_right_down): Add mouse event handlers, rename existing ones accoring
	to guidelines.
	(plot_canvas.zoom, rubberband): Implemented.
	(plot_window): Added. Provides a wxWindow with plot_canvas
	functionality.

	* interface.py (figure): Add possibility to add an externally created
	plot_canvas. Depends on plot_canvas.__type_hack__.

	* Local Variables:
	* mode: auto-fill
	* fill-column: 79
	* End:

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20011110/89d7962c/attachment.ksh>


More information about the SciPy-Dev mailing list