12 個の ImageView を含むアクティビティがあります。onCreate メソッドでは、BitmapFactory.decodeStream(...)を使用してこれらの ImageViews に 12 枚の写真を読み込みます。
このページに戻って 10 回戻ると、次のメモリ不足例外が発生します。
このエラーが発生する理由と、この例外を回避するためにリソースを解放するにはどうすればよいですか?
ありがとう、
04-24 14:41:00.050: D/TextView(7586): Constructor - Got appearance for textColorPrimaryInverse
04-24 14:41:00.050: D/TextView(7586): Constructor -- Got mEditTextBackgroundColor
04-24 14:41:00.130: I/dalvikvm-heap(7586): Clamp target GC heap from 48.878MB to 48.000MB
04-24 14:41:00.130: D/dalvikvm(7586): GC_FOR_ALLOC freed 495K, 2% free 47950K/48775K, paused 44ms
04-24 14:41:00.130: I/dalvikvm-heap(7586): Forcing collection of SoftReferences for 404616-byte allocation
04-24 14:41:00.180: I/dalvikvm-heap(7586): Clamp target GC heap from 48.856MB to 48.000MB
04-24 14:41:00.180: D/dalvikvm(7586): GC_BEFORE_OOM freed 23K, 2% free 47926K/48775K, paused 48ms
04-24 14:41:00.180: E/dalvikvm-heap(7586): Out of memory on a 404616-byte allocation.
04-24 14:41:00.180: I/dalvikvm(7586): "main" prio=5 tid=1 RUNNABLE
04-24 14:41:00.180: I/dalvikvm(7586): | group="main" sCount=0 dsCount=0 obj=0x40a54460 self=0x1ad5828
04-24 14:41:00.180: I/dalvikvm(7586): | sysTid=7586 nice=0 sched=0/0 cgrp=default handle=1074742408
04-24 14:41:00.180: I/dalvikvm(7586): | schedstat=( 14073874000 2242143000 19299 ) utm=1301 stm=106 core=1
04-24 14:41:00.180: I/dalvikvm(7586): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
04-24 14:41:00.180: I/dalvikvm(7586): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:493)
04-24 14:41:00.180: I/dalvikvm(7586): at org.mabna.order.utils.Utilities.decodeFile(Utilities.java:1220)
04-24 14:41:00.180: I/dalvikvm(7586): at org.mabna.order.businessLayer.db.BoInvProducts.getProductPhoto(BoInvProducts.java:107)
04-24 14:41:00.180: I/dalvikvm(7586): at org.mabna.order.ui.ActProductsGallery.loadPageImages(ActProductsGallery.java:729)
04-24 14:41:00.180: I/dalvikvm(7586): at org.mabna.order.ui.ActProductsGallery.selectItemInGallery(ActProductsGallery.java:611)
04-24 14:41:00.180: I/dalvikvm(7586): at org.mabna.order.ui.ActProductsGallery.onCreate(ActProductsGallery.java:315)
04-24 14:41:00.180: I/dalvikvm(7586): at android.app.Activity.performCreate(Activity.java:4465)
04-24 14:41:00.180: I/dalvikvm(7586): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
04-24 14:41:00.180: I/dalvikvm(7586): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
04-24 14:41:00.180: I/dalvikvm(7586): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
04-24 14:41:00.180: I/dalvikvm(7586): at android.app.ActivityThread.access$600(ActivityThread.java:123)
04-24 14:41:00.180: I/dalvikvm(7586): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
04-24 14:41:00.180: I/dalvikvm(7586): at android.os.Handler.dispatchMessage(Handler.java:99)
04-24 14:41:00.180: I/dalvikvm(7586): at android.os.Looper.loop(Looper.java:137)
04-24 14:41:00.180: I/dalvikvm(7586): at android.app.ActivityThread.main(ActivityThread.java:4424)
04-24 14:41:00.180: I/dalvikvm(7586): at java.lang.reflect.Method.invokeNative(Native Method)
04-24 14:41:00.180: I/dalvikvm(7586): at java.lang.reflect.Method.invoke(Method.java:511)
04-24 14:41:00.180: I/dalvikvm(7586): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-24 14:41:00.180: I/dalvikvm(7586): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-24 14:41:00.180: I/dalvikvm(7586): at dalvik.system.NativeStart.main(Native Method)
04-24 14:41:00.180: D/skia(7586): --- decoder->decode returned false
04-24 14:41:00.180: D/AndroidRuntime(7586): Shutting down VM
04-24 14:41:00.180: W/dalvikvm(7586): threadid=1: thread exiting with uncaught exception (group=0x40a531f8)
04-24 14:41:00.180: E/AndroidRuntime(7586): FATAL EXCEPTION: main
04-24 14:41:00.180: E/AndroidRuntime(7586): java.lang.OutOfMemoryError
04-24 14:41:00.180: E/AndroidRuntime(7586): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
04-24 14:41:00.180: E/AndroidRuntime(7586): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:493)
04-24 14:41:00.180: E/AndroidRuntime(7586): at org.mabna.order.utils.Utilities.decodeFile(Utilities.java:1220)
04-24 14:41:00.180: E/AndroidRuntime(7586): at org.mabna.order.businessLayer.db.BoInvProducts.getProductPhoto(BoInvProducts.java:107)
04-24 14:41:00.180: E/AndroidRuntime(7586): at org.mabna.order.ui.ActProductsGallery.loadPageImages(ActProductsGallery.java:729)
04-24 14:41:00.180: E/AndroidRuntime(7586): at org.mabna.order.ui.ActProductsGallery.selectItemInGallery(ActProductsGallery.java:611)
04-24 14:41:00.180: E/AndroidRuntime(7586): at org.mabna.order.ui.ActProductsGallery.onCreate(ActProductsGallery.java:315)
04-24 14:41:00.180: E/AndroidRuntime(7586): at android.app.Activity.performCreate(Activity.java:4465)
04-24 14:41:00.180: E/AndroidRuntime(7586): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
04-24 14:41:00.180: E/AndroidRuntime(7586): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
04-24 14:41:00.180: E/AndroidRuntime(7586): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
04-24 14:41:00.180: E/AndroidRuntime(7586): at android.app.ActivityThread.access$600(ActivityThread.java:123)
04-24 14:41:00.180: E/AndroidRuntime(7586): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
04-24 14:41:00.180: E/AndroidRuntime(7586): at android.os.Handler.dispatchMessage(Handler.java:99)
04-24 14:41:00.180: E/AndroidRuntime(7586): at android.os.Looper.loop(Looper.java:137)
04-24 14:41:00.180: E/AndroidRuntime(7586): at android.app.ActivityThread.main(ActivityThread.java:4424)
04-24 14:41:00.180: E/AndroidRuntime(7586): at java.lang.reflect.Method.invokeNative(Native Method)
04-24 14:41:00.180: E/AndroidRuntime(7586): at java.lang.reflect.Method.invoke(Method.java:511)
04-24 14:41:00.180: E/AndroidRuntime(7586): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-24 14:41:00.180: E/AndroidRuntime(7586): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-24 14:41:00.180: E/AndroidRuntime(7586): at dalvik.system.NativeStart.main(Native Method)
04-24 14:41:01.350: I/Process(7586): Sending signal. PID: 7586 SIG: 9