0

我在我的应用程序中遇到了 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 平板电脑上

4

1 回答 1

0

您无法捕获 OutofMemory 错误。
谷歌一下,有几十个 Pages 报道和讨论了 Android 中的 OoM。最常见的原因是巨大的静态变量或未回收的位图。以下是一些建议:BitmapFactory OOM 让我抓狂

于 2012-09-18T13:23:30.533 回答