总而言之,我在手机上遇到了内存不足的异常(4.4.4 MotoX)。拍照后,我从sdcard-path读取了照片,然后发生了异常。
12-18 11:12:47.294 11966-11966/com.geexfinance.geexfinance E/dalvikvm-heap﹕ Out of memory on a 42024976-byte allocation.
12-18 10:15:42.099 12905-12905/com.geexfinance.geexfinance E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.geexfinance.geexfinance, PID: 12905
java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
at android.graphics.BitmapFactory.decodeStreamInternal(BitmapFactory.java:620)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:596)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:634)
at com.geexfinance.geexfinance.model.GeexCache.getBitmap(GeexCache.java:1825)
at com.geexfinance.geexfinance.model.GeexCache.getBitmap(GeexCache.java:1940)
at com.geexfinance.geexfinance.ui.GeexApplyInstallmentFragment.onActivityResult(GeexApplyInstallmentFragment.java:532)
at android.app.Activity.dispatchActivityResult(Activity.java:5450)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3428)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3475)
at android.app.ActivityThread.access$1300(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1258)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5086)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
看起来很奇怪,我在Huawei-pad(4.4.3)上运行相同的应用程序,从来没有OOM发生。
我看着ANDROID_STUDIO的内存监视器。在我的手机上,从32MB分配到90MB的内存,而当内存大约为48MB时,总是会发生OOM异常。在我的平板电脑上,从32MB分配给40MB的内存永远不会达到OOM。
我有一些问题:
my phone have 2048MB memory ,why only a 42MB allocation leads a OOM?
设备的总RAM内存与每个应用程序实例分配的堆大小无关。
why OOM occurs when memory is 48MB,it's not a the memory peak.
如上所述,当请求的内存超过堆大小时,就会发生OOM。
same application, same user behavior(take 3 photos), why phone have a exception and pad not?
与无法复制OOM相关的因素很多,可能是照片的详细信息和大小,也可能是该时间点该应用程序的当前内存消耗。阅读有关如何有效处理大型Bitmap
s的文章,我相信问题将消失。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句