[OpenMap Users] Question about PanMouseMode and MouseWheel

From: Stéphane Wasserhardt <swasserhardt_at_cls.fr>
Date: Mon, 16 Oct 2006 09:05:39 +0200

Hi !

I'd like to know if there is a particular reason to instanciate new
BufferedImages each time PanMouseMode.createBuffers is called ?
I think this is only needed when the mapBean's width or height changes !

I ask this question because rotating the mouse wheel (numerous times) when
the panMouseMode is active causes many createBuffers calls. The garbage
collector doesn't have time enough to free the previous images thus causing
slowdowns... If you have not much memory available (try with -Xmx32m) and a
memory-consumming application, it can even cause OutOfMemoryErrors !

Another problem is multi-threading. Each time the wheel is rotated,
projectionChanged is called from a different worker thread. Each one of
these calls lead to a createBuffer call : images instances are uselessly
created one after the other! Instanciation can also happens during the
previous call's instanciation!

First, I think it would be better to flush the bufferedImages before
creating new instances, even if it won't change much... (have a look at
http://mindprod.com/jgloss/packratting.html ).
The createBuffer method should also be synchronized to be sure that the
images are completely instanciated before flushing and re-instanciating them...

For a real improvement, the images should only be instanciated when the
mapBean's size changes. In other cases re-instanciation is not needed
because the images are fully painted in the mouseDragged method.
I attached a new version of PanMouseMode. If I didn't miss anything, I
think it should be better to use this one instead of the current version...


[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Mon Oct 16 2006 - 03:09:33 EDT

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:07 EDT