From 4cfa9802ed20d1ba979ca95c75b39e5d2facd890 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Sun, 17 Jun 2012 12:28:44 +0200 Subject: Clear overlays cache to help with bitmap memory pressure The overlays cache can be rebuilt once per activity view. We can free the bitmap memory when we are not displaying overlays. --- main/src/cgeo/geocaching/maps/CGeoMap.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'main/src') diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java index 79ea44a..69c3530 100644 --- a/main/src/cgeo/geocaching/maps/CGeoMap.java +++ b/main/src/cgeo/geocaching/maps/CGeoMap.java @@ -174,7 +174,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto private static final int[][] INSET_USERMODIFIEDCOORDS = { { 21, 28, 0, 0 }, { 19, 25, 0, 0 } }; // bottom right, 12x12 / 26x26 private static final int[][] INSET_PERSONALNOTE = { { 0, 28, 21, 0 }, { 0, 25, 19, 0 } }; // bottom left, 12x12 / 26x26 - private static SparseArray overlaysCache = new SparseArray(); + private SparseArray overlaysCache = new SparseArray(); private int cachesCnt = 0; /** List of caches in the viewport */ private LeastRecentlyUsedSet caches = null; @@ -540,6 +540,8 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto mapView.destroyDrawingCache(); } + overlaysCache.clear(); + super.onPause(); } @@ -1664,7 +1666,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto .append(cache.getListId() > 0) .toHashCode(); - final LayerDrawable ldFromCache = CGeoMap.overlaysCache.get(hashcode); + final LayerDrawable ldFromCache = overlaysCache.get(hashcode); if (ldFromCache != null) { item.setMarker(ldFromCache); return item; @@ -1722,7 +1724,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto ld.setLayerInset(index++, inset[0], inset[1], inset[2], inset[3]); } - CGeoMap.overlaysCache.put(hashcode, ld); + overlaysCache.put(hashcode, ld); item.setMarker(ld); return item; -- cgit v1.1