Android dalvikvm-heap: Clamp target GC heap Android dalvikvm-heap: Clamp target GC heap android android

Android dalvikvm-heap: Clamp target GC heap


While this isn't the best answer I'd highly recommend you watch the video of the Memory management for Android Apps talk at Google IO 2011. It does a great job explaining how to manage memory and what the messages you are seeing actually mean.


You need to post your code for anyone to help. Otherwise i assume two things:

  • Since your phone is crashing, you must be doing something awesome which allows your program to run outside of the VM's allocated memory space.
  • Are you storing all of the contacts in a List or Array? If so, there's your problem. This is what Streams are good at fixing.

  • By downloading you mean fetching data from a remote location? It seems like you're keeping a lot of references to your data in memory. Do you have to? Depending on what you're trying to achieve, there's typically a few things you could try to minimize your memory footprint. To start with, I'd make sure I don't use any String references but I'd stream the data directly to the consumer. Also, try to process all your data in chunks. Do you also need to persist the data to the file system? If so, stream directly to the file system and avoid memory storage all together. If you post some code, that might help.