OutOfMemory

49 views
Skip to first unread message

GerhardS

unread,
Jun 26, 2012, 1:33:38 PM6/26/12
to mapsfo...@googlegroups.com
Hello everybody,
I know there are some problems with memory and bitmaps concerning the overlay.
When my MapActivity is hidden by another Activity and then shown again I get an OutOfMemory exception as shown:
 
Bitmap.createBitmap(int, int, Bitmap$Config) line: 468
PlaceOverlay(Overlay).changeSize() line: 409
PlaceOverlay(Overlay).run() line: 246
06-26 18:37:10.671: E/GraphicsJNI(4762): VM won't let us allocate 582400 bytes
where "PlaceOverlay" is a simple class extending "Overlay" and doing some painting in "drawOverlayBitmap".
Now I wonder whether 500kByte a reasonable size for a bitmap which is allocated for an overlay, or am I doing something wrong here? I also wonder why the changeSize() is called.
Is there a work around, like using a single overlay for doing all the work (currently I am using about 10 different overlays in my app).
I create and add the overlays in onStart() of the Activity and in onStop() I call mapView.getOverlays().clear(). Is there anything else I can do?
Fortunately this happens mostly while debugging but i am not sure about crashes when running without debugging.
Best regards and thank you for the excelent work,
Gerhard

Thilo Mühlberg

unread,
Jun 26, 2012, 1:52:08 PM6/26/12
to mapsfo...@googlegroups.com
This is a well known issue with the current overlay implementation. You
can find many similar discussions about it when you search the online
archive of this mailing list. There is also a short notice about the
memory consumption of an overlay in the wiki article, see:
https://code.google.com/p/mapsforge/wiki/OverlayAPI#Performance_and_limitations

The first workaround is to use less overlays, only 1-2 if possible. The
second workaround is to try the latest development version from our
repository which includes a rewritten overlay implementation. See the
corresponding issue
https://code.google.com/p/mapsforge/issues/detail?id=286 for more
details about that topic.

Greetings,
Thilo
signature.asc
Reply all
Reply to author
Forward
0 new messages