I am having an issue with drawing custom tiles over Google maps.
Using GoogleTileOverlay from OSMDroid, I am drawing custom tiles that are stored locally on the devices SD card.
The problem occurs after I have opened the map and then try to return to other activities. Things start getting weird. Background colors defined in XML aren’t showing up and other strange things.
I have searched far and wide for a reason and all I have been able to come up with is that there is not enough memory?
According to Eclipse MAT there is 8.4 MB of bitmaps left over after I have destroyed the activity that holds the MapView and GoogleTileOverlay
Let me know if there is any other information I can provide.
I was dealing with OOM exceptions due to memory leaks coming from the bitmaps. It seems that removing the overlay from
MapView‘sOverlaylist before clearing the tiles cache (so that no new tiles are created after the clearance) inonPauseof map activity works. I ended up having single instance ofLRUMapTileCacheno matter how many times the map activity was created / resumed.My
onPausebatch is as follows:The 8 MB still persist though(see edit), I’m using theandroid:largeHeap="true"application attribute to compensate.edit
Turned out those 8 MB came from other sources. The cache gets successfuly cleared with this.