I am plotting images of height and width equal to device screen as an overlay item in Android. But when the number of images exceeds the app crashes with Out Of Memory error – Bitmap exceeds VM budget. If I try to recycle it then the error comes as canvas trying to use recycled bitmap. What I need is to have the best way of plotting lots of images over map. The images comes from the server and I also need to cache the images. For caching currently I am doing that in LinkedHashMap but I guess even this will create problems as I am storing the drawable objects.
Is there any example of using plotting large bitmaps on maps?
Each application has very limited amounts of memory (often 16MB, but I’ve seen as low as 14MB, and as high as 32MB). This is specific to the firmware running on each device. The application class can be inherited to provide access to a “LowMemory” function, which can alert you when your application has used almost all of its memory.
You shouldn’t have problems with images the size of the screen, but make sure they’re not ridiculously over-sized (have them as small as possible).
I’d also recommend checking out the memory stat in Eclipse to see how much memory your application is using (to see how it grows etc).
This error is one of the most annoying errors when dealing with Maps and Android and you will find plenty of other posts related to this issue here on SO