MapView中的OutOfMemoryError

时间:2012-09-18 13:14:39

标签: android google-maps android-mapview google-maps-mobile

我在我的应用程序中遇到了OutOfMemoryError,但是在我的代码中我没有看到如何处理/捕获它的方法。任何想法如何预防/解决?

java.lang.OutOfMemoryError
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
at android.graphics.Bitmap.createBitmap(Bitmap.java:585)
at com.google.android.maps.ZoomHelper.createSnapshot(ZoomHelper.java:444)
at com.google.android.maps.ZoomHelper.beginZoom(ZoomHelper.java:194)
at com.google.android.maps.MapView$2.onScaleBegin(MapView.java:380)
at android.view.ScaleGestureDetector.onTouchEvent(ScaleGestureDetector.java:261)
at com.google.android.maps.MapView.onTouchEvent(MapView.java:682)
at android.view.View.dispatchTouchEvent(View.java:5552)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1951)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1712)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1928)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1376)
at android.app.Activity.dispatchTouchEvent(Activity.java:2364)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1876)
at android.view.View.dispatchPointerEvent(View.java:5736)
at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:2920)
at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2473)
at android.view.ViewRootImpl.processInputEvents(ViewRootImpl.java:847)
at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2482)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)

发生在使用Android 4.0.3的ThinkPad Tablet上

1 个答案:

答案 0 :(得分:0)

您无法捕获OutofMemory错误。
只是谷歌它,有几十页报告和讨论Android中的OoMs。 最常见的原因是巨大的静态变量或位图,它们不会被回收。 以下是一些建议:BitmapFactory OOM driving me nuts