我的应用使用Google Maps V2。 这一切在其他设备上运行正常,但是当我在HTC Wildfire S上打开地图活动时,经过几分钟的地图导航后,我收到此错误:
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
我的地图上有数百个标记,这可能会使内存饱和吗?
答案 0 :(得分:1)
我没有Wildfire S可以检查,但我想如果你添加它:
Toast.makeText(this, String.valueOf((Runtime.getRuntime().maxMemory() / 1024 / 1024)),
Toast.LENGTH_SHORT).show();
在应用程序开头的某个地方并在设备上运行它,toast将显示16.这是您的应用程序可以以MB为单位分配的最大堆。您的其他测试设备可能有不同的限制。作为一个例子,我的Desire HD(运行PACman JellyBean)的限制是48MB。对于AVD,可以将此限制设置为配置的一部分。在某些情况下可以覆盖此限制,How to increase heap size of an android application?会提供一些好的信息。
你是否需要那么多的Ram和更多是另一个问题和我们无法在没有关于代码和设计的更多信息的情况下推测的东西。但是,请查看最近的问题android maps, markers and memory leaks。
最后,如果这一切对您而言是新的,那么仍然值得观看Google IO 2011演示文稿:Memory Management for Android Apps.