3

My app uses Google Maps V2. It all works fine on other devices, but when I open the map activity on HTC Wildfire S, after some minutes of navigation of the map, I get this error:

07-23 18:16:08.556: E/AndroidRuntime(3316): FATAL EXCEPTION: vts_com.fedrasoft.craiinforma
07-23 18:16:08.556: E/AndroidRuntime(3316): java.lang.OutOfMemoryError: (Heap Size=16071KB, Allocated=11771KB, Bitmap Size=4445KB)
07-23 18:16:08.556: E/AndroidRuntime(3316):     at maps.ap.d.a(Unknown Source)
07-23 18:16:08.556: E/AndroidRuntime(3316):     at maps.i.ct.a(Unknown Source)
07-23 18:16:08.556: E/AndroidRuntime(3316):     at maps.k.ah.a(Unknown Source)
07-23 18:16:08.556: E/AndroidRuntime(3316):     at maps.k.d.a(Unknown Source)
07-23 18:16:08.556: E/AndroidRuntime(3316):     at maps.k.g.handleMessage(Unknown Source)
07-23 18:16:08.556: E/AndroidRuntime(3316):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-23 18:16:08.556: E/AndroidRuntime(3316):     at android.os.Looper.loop(Looper.java:150)
07-23 18:16:08.556: E/AndroidRuntime(3316):     at maps.k.d.b(Unknown Source)
07-23 18:16:08.556: E/AndroidRuntime(3316):     at maps.k.ag.b(Unknown Source)
07-23 18:16:08.556: E/AndroidRuntime(3316):     at maps.ap.b.run(Unknown Source)
07-23 18:16:09.427: E/dalvikvm-heap(3316): Out of memory on a 25862-byte allocation.
07-23 18:16:09.437: E/dalvikvm(3316): Out of memory: Heap Size=16071KB, Allocated=11768KB, Bitmap Size=4445KB, Limit=20480KB
07-23 18:16:09.437: E/dalvikvm(3316): Extra info: Footprint=16071KB, Allowed Footprint=16071KB, Trimmed=1172KB
07-23 18:16:10.248: E/dalvikvm-heap(3316): Out of memory on a 25058-byte allocation.
07-23 18:16:10.258: E/dalvikvm(3316): Out of memory: Heap Size=16071KB, Allocated=11779KB, Bitmap Size=4445KB, Limit=20480KB
07-23 18:16:10.258: E/dalvikvm(3316): Extra info: Footprint=16071KB, Allowed Footprint=16071KB, Trimmed=1172KB
07-23 18:16:10.919: E/dalvikvm-heap(3316): Out of memory on a 38575-byte allocation.
07-23 18:16:10.929: E/dalvikvm(3316): Out of memory: Heap Size=16071KB, Allocated=11789KB, Bitmap Size=4445KB, Limit=20480KB
07-23 18:16:10.929: E/dalvikvm(3316): Extra info: Footprint=16071KB, Allowed Footprint=16071KB, Trimmed=1172KB
07-23 18:16:11.659: E/dalvikvm-heap(3316): Out of memory on a 25050-byte allocation.
07-23 18:16:11.669: E/dalvikvm(3316): Out of memory: Heap Size=16071KB, Allocated=11763KB, Bitmap Size=4445KB, Limit=20480KB
07-23 18:16:11.669: E/dalvikvm(3316): Extra info: Footprint=16071KB, Allowed Footprint=16071KB, Trimmed=1172KB
07-23 18:16:12.020: E/dalvikvm-heap(3316): Out of memory on a 25862-byte allocation.
07-23 18:16:12.030: E/dalvikvm(3316): Out of memory: Heap Size=16071KB, Allocated=11765KB, Bitmap Size=4445KB, Limit=20480KB
07-23 18:16:12.030: E/dalvikvm(3316): Extra info: Footprint=16071KB, Allowed Footprint=16071KB, Trimmed=1172KB
07-23 18:16:12.791: E/dalvikvm-heap(3316): Out of memory on a 38575-byte allocation.
07-23 18:16:12.801: E/dalvikvm(3316): Out of memory: Heap Size=16071KB, Allocated=11774KB, Bitmap Size=4445KB, Limit=20480KB
07-23 18:16:12.801: E/dalvikvm(3316): Extra info: Footprint=16071KB, Allowed Footprint=16071KB, Trimmed=1172KB
07-23 18:16:13.681: E/dalvikvm-heap(3316): Out of memory on a 25862-byte allocation.
07-23 18:16:13.691: E/dalvikvm(3316): Out of memory: Heap Size=16071KB, Allocated=11773KB, Bitmap Size=4445KB, Limit=20480KB
07-23 18:16:13.691: E/dalvikvm(3316): Extra info: Footprint=16071KB, Allowed Footprint=16071KB, Trimmed=1172KB
07-23 18:16:14.232: E/dalvikvm-heap(3316): Out of memory on a 25058-byte allocation.
07-23 18:16:14.242: E/dalvikvm(3316): Out of memory: Heap Size=16071KB, Allocated=11768KB, Bitmap Size=4445KB, Limit=20480KB
07-23 18:16:14.242: E/dalvikvm(3316): Extra info: Footprint=16071KB, Allowed Footprint=16071KB, Trimmed=1172KB
07-23 18:16:14.973: E/dalvikvm-heap(3316): Out of memory on a 38575-byte allocation.
07-23 18:16:14.983: E/dalvikvm(3316): Out of memory: Heap Size=16071KB, Allocated=11781KB, Bitmap Size=4445KB, Limit=20480KB
07-23 18:16:14.983: E/dalvikvm(3316): Extra info: Footprint=16071KB, Allowed Footprint=16071KB, Trimmed=1172KB
07-23 18:16:15.333: E/dalvikvm-heap(3316): Out of memory on a 25854-byte allocation.
07-23 18:16:15.343: E/dalvikvm(3316): Out of memory: Heap Size=16071KB, Allocated=11778KB, Bitmap Size=4445KB, Limit=20480KB
07-23 18:16:15.343: E/dalvikvm(3316): Extra info: Footprint=16071KB, Allowed Footprint=16071KB, Trimmed=1172KB

I have some hundreds of markers on my map, this could saturate the memory?

Chilledrat
  • 2,593
  • 3
  • 28
  • 38
Umberto
  • 2,011
  • 1
  • 23
  • 27
  • 1
    I guess "hundreds" of markers MAY be the cause for this error. Did you try removing some apps from the phone and clearing the RAM usage? – Kunal S. Kushwah Jul 23 '13 at 18:17
  • @KunalS.Kushwah The phone is almost "empty", it has few apps installed. I'll try clearing the RAM before navigating the map, and I'll let you know. Thanks! – Umberto Jul 24 '13 at 07:00
  • How do the other test devices compare in terms of Ram available? Also, if your Wildfire is still running the stock rom, then you might be aware that Sense is going to eat *some* Ram compared to a vanilla version of Gingerbread. – Chilledrat Jul 24 '13 at 16:25
  • @KunalS.Kushwah clearing the RAM didn't solve the problem. – Umberto Jul 24 '13 at 21:51
  • @Chilledrat the HTC Wildfire S has 384MB of RAM (about 258MB free before starting my app), more than other devices in which the map works fine instead! I think the device is running the stock ROM. How can I know if Sense is going to eat some RAM? – Umberto Jul 24 '13 at 21:59
  • Sorry, my comment on Sense could have been worded better :) I just wanted to ensure you were aware that similar spec. devices running stock android would have more Ram available than than one running Sense. – Chilledrat Jul 25 '13 at 08:23

1 Answers1

1

I don't have a Wildfire S to check, but I guess if you add this:

Toast.makeText(this, String.valueOf((Runtime.getRuntime().maxMemory() / 1024 / 1024)),
       Toast.LENGTH_SHORT).show();

somewhere at the beginning of your app and run it on the device the toast will show 16. This is the maximum heap your app can allocate in MB. Possibly your other test devices have different limits. As an example the limit my Desire HD (running the PACman JellyBean) is 48MB. For AVDs this can limit can be set as part of the configuration. It is possible to override this limit in some cases and How to increase heap size of an android application? gives some good info.

Whether you need that amount of Ram and more is another question and something that we can't speculate on without more information on the code and design. However, have a look at the recent question android maps, markers and memory leaks.

Finally, if all this is new to you then it is still worth watching the Google IO 2011 presentation: Memory Management for Android Apps.

Community
  • 1
  • 1
Chilledrat
  • 2,593
  • 3
  • 28
  • 38