In my Activity I have the following code:
int picture = Const.a1;
Const.backgroundBitmap = BitmapFactory.decodeResource(getResources(), picture);
Const.backgroundBitmapBonus0 = BitmapFactory.decodeResource(getResources(), Const.bonus_back[0]);
Const.backgroundBitmapBonus1 = BitmapFactory.decodeResource(getResources(), Const.bonus_back[1]);
Const.backgroundBitmapBonus2 = BitmapFactory.decodeResource(getResources(), Const.bonus_back[2]);
Const.backgroundBitmapBonus3 = BitmapFactory.decodeResource(getResources(), Const.bonus_back[3]);
Const.bitmapBackBonus = new Bitmap[4];
Const.bitmapBackBonus[0]= Const.backgroundBitmapBonus0;
Const.bitmapBackBonus[1] = Const.backgroundBitmapBonus1;
Const.bitmapBackBonus[2] = Const.backgroundBitmapBonus2;
Const.bitmapBackBonus[3] = Const.backgroundBitmapBonus3;
And in Const class I have
public static int[] bonus_back = { R.drawable.back_b0 , R.drawable.back_b1 , R.drawable.back_b2 , R.drawable.back_b3};
When I run the app on my device it crashes, while in AVD it worked fine.
How can I use these pictures in right way?
EDIT:
new code using http://developer.android.com/training/displaying-bitmaps/load-bitmap.html
still the same problem
Const.screenWidth = this.getWindowManager().getDefaultDisplay().getWidth();
Const.screenHeight = this.getWindowManager().getDefaultDisplay().getHeight();
int picture = Const.a1;
Const.backgroundBitmapBonus0 = decodeSampledBitmapFromResource(getResources(), Const.bonus_back[0], Const.screenWidth, Const.screenHeight);
Const.backgroundBitmapBonus1 =decodeSampledBitmapFromResource(getResources(), Const.bonus_back[1], Const.screenWidth, Const.screenHeight);
Const.backgroundBitmapBonus2 = decodeSampledBitmapFromResource(getResources(), Const.bonus_back[2], Const.screenWidth, Const.screenHeight);
Const.backgroundBitmapBonus3 = decodeSampledBitmapFromResource(getResources(), Const.bonus_back[3], Const.screenWidth, Const.screenHeight);
Const.backgroundBitmap = decodeSampledBitmapFromResource(getResources(), picture, 100, 100);
/*Const.backgroundBitmap = BitmapFactory.decodeResource(getResources(), picture);
Const.backgroundBitmapBonus0 = BitmapFactory.decodeResource(getResources(), Const.bonus_back[0]);
Const.backgroundBitmapBonus1 = BitmapFactory.decodeResource(getResources(), Const.bonus_back[1]);
Const.backgroundBitmapBonus2 = BitmapFactory.decodeResource(getResources(), Const.bonus_back[2]);
Const.backgroundBitmapBonus3 = BitmapFactory.decodeResource(getResources(), Const.bonus_back[3]);
*/
Const.bitmapBackBonus = new Bitmap[4];
Const.bitmapBackBonus[0]= Const.backgroundBitmapBonus0;
Const.bitmapBackBonus[1] = Const.backgroundBitmapBonus1;
Const.bitmapBackBonus[2] = Const.backgroundBitmapBonus2;
Const.bitmapBackBonus[3] = Const.backgroundBitmapBonus3;
EDIT 2 : Logcat
11-14 09:45:45.525: D/dalvikvm(5623): Late-enabling CheckJNI
11-14 09:45:45.805: D/skia(5623): ---- fAsset->read(3346) returned 0
11-14 09:45:45.905: D/dalvikvm(5623): GC_FOR_ALLOC freed 99K, 3% free 13923K/14343K, paused 37ms
11-14 09:45:45.905: I/dalvikvm-heap(5623): Grow heap (frag case) to 14.807MB for 992016-byte allocation
11-14 09:45:45.945: D/dalvikvm(5623): GC_CONCURRENT freed 1K, 4% free 14890K/15367K, paused 2ms+2ms
11-14 09:45:46.025: D/dalvikvm(5623): GC_FOR_ALLOC freed 0K, 4% free 14890K/15367K, paused 13ms
11-14 09:45:46.075: I/dalvikvm-heap(5623): Grow heap (frag case) to 29.942MB for 15872016-byte allocation
11-14 09:45:46.115: D/dalvikvm(5623): GC_CONCURRENT freed 0K, 2% free 30390K/30919K, paused 2ms+2ms
11-14 09:45:46.515: D/dalvikvm(5623): GC_FOR_ALLOC freed 969K, 5% free 30391K/31943K, paused 18ms
11-14 09:45:46.565: I/dalvikvm-heap(5623): Grow heap (frag case) to 45.080MB for 15872016-byte allocation
11-14 09:45:46.595: D/dalvikvm(5623): GC_CONCURRENT freed <1K, 4% free 45890K/47495K, paused 2ms+3ms
11-14 09:45:46.905: D/dalvikvm(5623): GC_FOR_ALLOC freed 969K, 4% free 45891K/47495K, paused 15ms
11-14 09:45:46.970: I/dalvikvm-heap(5623): Grow heap (frag case) to 60.216MB for 15872016-byte allocation
11-14 09:45:46.990: D/dalvikvm(5623): GC_FOR_ALLOC freed <1K, 3% free 61391K/63047K, paused 18ms
11-14 09:45:47.050: D/dalvikvm(5623): GC_CONCURRENT freed 0K, 3% free 61391K/63047K, paused 2ms+5ms
11-14 09:45:47.345: D/dalvikvm(5623): GC_FOR_ALLOC freed 969K, 3% free 61391K/63047K, paused 14ms
11-14 09:45:47.345: I/dalvikvm-heap(5623): Forcing collection of SoftReferences for 15872016-byte allocation
11-14 09:45:47.390: D/dalvikvm(5623): GC_BEFORE_OOM freed 9K, 3% free 61382K/63047K, paused 32ms
11-14 09:45:47.390: E/dalvikvm-heap(5623): Out of memory on a 15872016-byte allocation.
11-14 09:45:47.390: I/dalvikvm(5623): "main" prio=5 tid=1 RUNNABLE
11-14 09:45:47.390: I/dalvikvm(5623): | group="main" sCount=0 dsCount=0 obj=0x40c6d460 self=0x8a9288
11-14 09:45:47.390: I/dalvikvm(5623): | sysTid=5623 nice=0 sched=0/0 cgrp=default handle=1074558216
11-14 09:45:47.390: I/dalvikvm(5623): | schedstat=( 1288354466 258529951 3812 ) utm=106 stm=22 core=2
11-14 09:45:47.390: I/dalvikvm(5623): at android.graphics.Bitmap.nativeCreate(Native Method)
11-14 09:45:47.390: I/dalvikvm(5623): at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
11-14 09:45:47.390: I/dalvikvm(5623): at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
11-14 09:45:47.390: I/dalvikvm(5623): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
11-14 09:45:47.390: I/dalvikvm(5623): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:618)
11-14 09:45:47.390: I/dalvikvm(5623): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:593)
11-14 09:45:47.390: I/dalvikvm(5623): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:445)
11-14 09:45:47.390: I/dalvikvm(5623): at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:468)
11-14 09:45:47.390: I/dalvikvm(5623): at com.example.fishe.FullscreenActivity.decodeSampledBitmapFromResource(FullscreenActivity.java:248)
11-14 09:45:47.390: I/dalvikvm(5623): at com.example.fishe.FullscreenActivity.onCreate(FullscreenActivity.java:142)
11-14 09:45:47.390: I/dalvikvm(5623): at android.app.Activity.performCreate(Activity.java:4533)
11-14 09:45:47.395: I/dalvikvm(5623): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
11-14 09:45:47.395: I/dalvikvm(5623): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
11-14 09:45:47.395: I/dalvikvm(5623): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
11-14 09:45:47.395: I/dalvikvm(5623): at android.app.ActivityThread.access$600(ActivityThread.java:128)
11-14 09:45:47.395: I/dalvikvm(5623): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
11-14 09:45:47.395: I/dalvikvm(5623): at android.os.Handler.dispatchMessage(Handler.java:99)
11-14 09:45:47.395: I/dalvikvm(5623): at android.os.Looper.loop(Looper.java:137)
11-14 09:45:47.395: I/dalvikvm(5623): at android.app.ActivityThread.main(ActivityThread.java:4517)
11-14 09:45:47.395: I/dalvikvm(5623): at java.lang.reflect.Method.invokeNative(Native Method)
11-14 09:45:47.395: I/dalvikvm(5623): at java.lang.reflect.Method.invoke(Method.java:511)
11-14 09:45:47.395: I/dalvikvm(5623): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
11-14 09:45:47.395: I/dalvikvm(5623): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
11-14 09:45:47.395: I/dalvikvm(5623): at dalvik.system.NativeStart.main(Native Method)
11-14 09:45:47.395: D/AndroidRuntime(5623): Shutting down VM
11-14 09:45:47.395: W/dalvikvm(5623): threadid=1: thread exiting with uncaught exception (group=0x40c6c1f8)
11-14 09:45:47.395: E/AndroidRuntime(5623): FATAL EXCEPTION: main
11-14 09:45:47.395: E/AndroidRuntime(5623): java.lang.OutOfMemoryError
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.graphics.Bitmap.nativeCreate(Native Method)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:618)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:593)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:445)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:468)
11-14 09:45:47.395: E/AndroidRuntime(5623): at com.example.fishe.FullscreenActivity.decodeSampledBitmapFromResource(FullscreenActivity.java:248)
11-14 09:45:47.395: E/AndroidRuntime(5623): at com.example.fishe.FullscreenActivity.onCreate(FullscreenActivity.java:142)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.app.Activity.performCreate(Activity.java:4533)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.app.ActivityThread.access$600(ActivityThread.java:128)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.os.Handler.dispatchMessage(Handler.java:99)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.os.Looper.loop(Looper.java:137)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.app.ActivityThread.main(ActivityThread.java:4517)
11-14 09:45:47.395: E/AndroidRuntime(5623): at java.lang.reflect.Method.invokeNative(Native Method)
11-14 09:45:47.395: E/AndroidRuntime(5623): at java.lang.reflect.Method.invoke(Method.java:511)
11-14 09:45:47.395: E/AndroidRuntime(5623): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
11-14 09:45:47.395: E/AndroidRuntime(5623): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
11-14 09:45:47.395: E/AndroidRuntime(5623): at dalvik.system.NativeStart.main(Native Method)
11-14 09:45:56.490: I/Process(5623): Sending signal. PID: 5623 SIG: 9
If the image is too big you're probably running out of memory.
Check http://developer.android.com/training/displaying-bitmaps/load-bitmap.html to learn how to load a scaled-down version of the image.
Related
I'm having a weird issue.
I've created an app which works fine on a Samsung Galaxy S2 (heap size 48MB) but when I test it on a Motorola Xoom (heap size also 48MB) it exits with an OutOfMemory error.
This is particularly strange since from what I can tell I'm only actually loading about 20MB of data into the heap.
The crash occurs at the same place every time, it's when I'm loading the dictionary file into a Vector (the app is a word-game, and the dictionary file that is being loaded is about 2MB and resides in the assets folder). The dictionary makes it about as far as the words starting with R and then gives up the ghost.
The Samsung is running Android 2.2 and the Xoom is running 4.0.3
Here's the code which loads the dictionary:
public class Dictionary {
Vector words = new Vector();
public Dictionary() {
}
public void loadWords(String dFile) {
try {
InputStream is = AndroidFileIO.assets.open(dFile);
BufferedReader f = new BufferedReader(new InputStreamReader(is), 8192);
String word = null;
if (is != null) {
while ((word = f.readLine()) != null) {
words.addElement(word.toUpperCase());
}
}
is.close();
f = null;
} catch (Exception e) {
System.err.println("Unable to read from " + dFile);
// continue with empty dictionary
}
}
...and here's the LogCat output:
01-27 17:16:12.750: D/dalvikvm(9050): GC_FOR_ALLOC freed 63K, 4% free 6529K/6787K, paused 53ms
01-27 17:16:12.760: I/dalvikvm-heap(9050): Grow heap (frag case) to 8.383MB for 2048016-byte allocation
01-27 17:16:12.810: D/dalvikvm(9050): GC_CONCURRENT freed <1K, 4% free 8529K/8839K, paused 2ms+8ms
01-27 17:16:12.870: D/dalvikvm(9050): GC_FOR_ALLOC freed 20K, 4% free 8543K/8839K, paused 25ms
01-27 17:16:12.890: I/dalvikvm-heap(9050): Grow heap (frag case) to 12.302MB for 4096016-byte allocation
01-27 17:16:12.940: D/dalvikvm(9050): GC_FOR_ALLOC freed 0K, 3% free 12543K/12871K, paused 24ms
01-27 17:16:12.980: D/dalvikvm(9050): GC_CONCURRENT freed <1K, 3% free 12543K/12871K, paused 3ms+3ms
01-27 17:16:13.350: D/libEGL(9050): loaded /system/lib/egl/libGLES_android.so
01-27 17:16:13.360: D/libEGL(9050): loaded /system/lib/egl/libEGL_tegra.so
01-27 17:16:13.390: D/libEGL(9050): loaded /system/lib/egl/libGLESv1_CM_tegra.so
01-27 17:16:13.400: D/libEGL(9050): loaded /system/lib/egl/libGLESv2_tegra.so
01-27 17:16:13.440: D/OpenGLRenderer(9050): Enabling debug mode 0
01-27 17:16:13.840: D/dalvikvm(9050): GC_FOR_ALLOC freed 11K, 1% free 14001K/14087K, paused 20ms
01-27 17:16:13.890: D/dalvikvm(9050): GC_CONCURRENT freed 1K, 1% free 16000K/16135K, paused 2ms+3ms
01-27 17:16:13.990: D/dalvikvm(9050): GC_FOR_ALLOC freed <1K, 1% free 16001K/16135K, paused 19ms
01-27 17:16:14.000: I/dalvikvm-heap(9050): Grow heap (frag case) to 19.585MB for 4096016-byte allocation
01-27 17:16:14.060: D/dalvikvm(9050): GC_CONCURRENT freed <1K, 1% free 20001K/20167K, paused 1ms+20ms
01-27 17:16:14.370: D/dalvikvm(9050): GC_FOR_ALLOC freed <1K, 1% free 20001K/20167K, paused 17ms
01-27 17:16:14.380: I/dalvikvm-heap(9050): Grow heap (frag case) to 21.540MB for 2048016-byte allocation
01-27 17:16:14.420: D/dalvikvm(9050): GC_CONCURRENT freed <1K, 1% free 22001K/22215K, paused 2ms+3ms
01-27 17:16:14.510: D/dalvikvm(9050): GC_FOR_ALLOC freed <1K, 1% free 22001K/22215K, paused 17ms
01-27 17:16:14.520: I/dalvikvm-heap(9050): Grow heap (frag case) to 25.446MB for 4096016-byte allocation
01-27 17:16:14.540: D/dalvikvm(9050): GC_CONCURRENT freed <1K, 1% free 26001K/26247K, paused 2ms+3ms
01-27 17:16:14.840: D/dalvikvm(9050): GC_FOR_ALLOC freed <1K, 1% free 26001K/26247K, paused 20ms
01-27 17:16:14.840: I/dalvikvm-heap(9050): Grow heap (frag case) to 27.399MB for 2048016-byte allocation
01-27 17:16:14.870: D/dalvikvm(9050): GC_CONCURRENT freed <1K, 2% free 28001K/28295K, paused 1ms+3ms
01-27 17:16:15.070: D/dalvikvm(9050): GC_FOR_ALLOC freed <1K, 2% free 28389K/28743K, paused 20ms
01-27 17:16:15.080: I/dalvikvm-heap(9050): Grow heap (frag case) to 31.683MB for 4096016-byte allocation
01-27 17:16:15.130: D/dalvikvm(9050): GC_CONCURRENT freed <1K, 2% free 32388K/32775K, paused 2ms+3ms
01-27 17:16:15.220: D/dalvikvm(9050): GC_FOR_ALLOC freed 1K, 2% free 32390K/32775K, paused 19ms
01-27 17:16:15.220: I/dalvikvm-heap(9050): Grow heap (frag case) to 35.591MB for 4096016-byte allocation
01-27 17:16:15.260: D/dalvikvm(9050): GC_CONCURRENT freed <1K, 2% free 36390K/36807K, paused 1ms+4ms
01-27 17:16:16.510: D/dalvikvm(9050): GC_CONCURRENT freed 554K, 2% free 37925K/38535K, paused 2ms+5ms
01-27 17:16:16.940: D/dalvikvm(9050): GC_CONCURRENT freed 1047K, 3% free 38914K/40071K, paused 2ms+6ms
01-27 17:16:17.150: D/dalvikvm(9050): GC_CONCURRENT freed 982K, 3% free 39891K/41031K, paused 2ms+8ms
01-27 17:16:17.430: D/dalvikvm(9050): GC_CONCURRENT freed 1012K, 3% free 40876K/42055K, paused 2ms+8ms
01-27 17:16:17.770: D/dalvikvm(9050): GC_FOR_ALLOC freed 997K, 3% free 41820K/43015K, paused 65ms
01-27 17:16:18.100: D/dalvikvm(9050): GC_FOR_ALLOC freed 989K, 3% free 42757K/43975K, paused 75ms
01-27 17:16:18.480: D/dalvikvm(9050): GC_FOR_ALLOC freed 950K, 3% free 43636K/44871K, paused 81ms
01-27 17:16:18.780: D/dalvikvm(9050): GC_FOR_ALLOC freed 940K, 3% free 44525K/45767K, paused 84ms
01-27 17:16:19.130: D/dalvikvm(9050): GC_FOR_ALLOC freed 946K, 3% free 45421K/46663K, paused 94ms
01-27 17:16:19.410: D/dalvikvm(9050): GC_FOR_ALLOC freed 905K, 3% free 46303K/47559K, paused 99ms
01-27 17:16:19.770: I/dalvikvm-heap(9050): Clamp target GC heap from 48.105MB to 48.000MB
01-27 17:16:19.770: D/dalvikvm(9050): GC_FOR_ALLOC freed 897K, 3% free 47157K/48455K, paused 106ms
01-27 17:16:20.050: I/dalvikvm-heap(9050): Clamp target GC heap from 48.855MB to 48.000MB
01-27 17:16:20.050: D/dalvikvm(9050): GC_FOR_ALLOC freed 793K, 3% free 47924K/49159K, paused 112ms
01-27 17:16:20.220: I/dalvikvm-heap(9050): Clamp target GC heap from 49.239MB to 48.000MB
01-27 17:16:20.220: D/dalvikvm(9050): GC_FOR_ALLOC freed 396K, 2% free 48317K/49159K, paused 112ms
01-27 17:16:20.360: I/dalvikvm-heap(9050): Clamp target GC heap from 49.439MB to 48.000MB
01-27 17:16:20.360: D/dalvikvm(9050): GC_FOR_ALLOC freed 206K, 2% free 48523K/49159K, paused 109ms
01-27 17:16:20.480: I/dalvikvm-heap(9050): Clamp target GC heap from 49.541MB to 48.000MB
01-27 17:16:20.480: D/dalvikvm(9050): GC_FOR_ALLOC freed 104K, 2% free 48626K/49159K, paused 107ms
01-27 17:16:20.600: I/dalvikvm-heap(9050): Clamp target GC heap from 49.592MB to 48.000MB
01-27 17:16:20.600: D/dalvikvm(9050): GC_FOR_ALLOC freed 53K, 1% free 48679K/49159K, paused 111ms
01-27 17:16:20.720: I/dalvikvm-heap(9050): Clamp target GC heap from 49.618MB to 48.000MB
01-27 17:16:20.730: D/dalvikvm(9050): GC_FOR_ALLOC freed 26K, 1% free 48706K/49159K, paused 117ms
01-27 17:16:20.830: I/dalvikvm-heap(9050): Clamp target GC heap from 49.628MB to 48.000MB
01-27 17:16:20.830: D/dalvikvm(9050): GC_FOR_ALLOC freed 11K, 1% free 48717K/49159K, paused 105ms
01-27 17:16:20.950: I/dalvikvm-heap(9050): Clamp target GC heap from 49.631MB to 48.000MB
01-27 17:16:20.950: D/dalvikvm(9050): GC_FOR_ALLOC freed 2K, 1% free 48719K/49159K, paused 114ms
01-27 17:16:21.060: I/dalvikvm-heap(9050): Clamp target GC heap from 49.633MB to 48.000MB
01-27 17:16:21.060: D/dalvikvm(9050): GC_FOR_ALLOC freed 1K, 1% free 48721K/49159K, paused 112ms
01-27 17:16:21.170: I/dalvikvm-heap(9050): Clamp target GC heap from 49.636MB to 48.000MB
01-27 17:16:21.170: D/dalvikvm(9050): GC_FOR_ALLOC freed 3K, 1% free 48724K/49159K, paused 108ms
01-27 17:16:21.170: I/dalvikvm-heap(9050): Forcing collection of SoftReferences for 176-byte allocation
01-27 17:16:21.300: I/dalvikvm-heap(9050): Clamp target GC heap from 49.628MB to 48.000MB
01-27 17:16:21.300: D/dalvikvm(9050): GC_BEFORE_OOM freed 9K, 1% free 48715K/49159K, paused 127ms
01-27 17:16:21.410: I/dalvikvm-heap(9050): Clamp target GC heap from 49.635MB to 48.000MB
01-27 17:16:21.410: D/dalvikvm(9050): GC_FOR_ALLOC freed 8K, 1% free 48722K/49159K, paused 108ms
01-27 17:16:21.520: I/dalvikvm-heap(9050): Clamp target GC heap from 49.639MB to 48.000MB
01-27 17:16:21.520: D/dalvikvm(9050): GC_FOR_ALLOC freed 4K, 1% free 48727K/49159K, paused 109ms
01-27 17:16:21.620: I/dalvikvm-heap(9050): Clamp target GC heap from 49.641MB to 48.000MB
01-27 17:16:21.620: D/dalvikvm(9050): GC_FOR_ALLOC freed 2K, 1% free 48729K/49159K, paused 109ms
01-27 17:16:21.730: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:21.730: D/dalvikvm(9050): GC_FOR_ALLOC freed 1K, 1% free 48730K/49159K, paused 105ms
01-27 17:16:21.840: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:21.840: D/dalvikvm(9050): GC_FOR_ALLOC freed <1K, 1% free 48730K/49159K, paused 110ms
01-27 17:16:21.950: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:21.950: D/dalvikvm(9050): GC_FOR_ALLOC freed <1K, 1% free 48730K/49159K, paused 106ms
01-27 17:16:22.050: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:22.050: D/dalvikvm(9050): GC_FOR_ALLOC freed 0K, 1% free 48730K/49159K, paused 106ms
01-27 17:16:22.050: I/dalvikvm-heap(9050): Forcing collection of SoftReferences for 44-byte allocation
01-27 17:16:22.170: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:22.170: D/dalvikvm(9050): GC_BEFORE_OOM freed 0K, 1% free 48730K/49159K, paused 119ms
01-27 17:16:22.170: E/dalvikvm-heap(9050): Out of memory on a 44-byte allocation.
01-27 17:16:22.170: I/dalvikvm(9050): "Thread-1489" prio=5 tid=13 RUNNABLE
01-27 17:16:22.170: I/dalvikvm(9050): | group="main" sCount=0 dsCount=0 obj=0x417e7bd8 self=0x1a6a168
01-27 17:16:22.170: I/dalvikvm(9050): | sysTid=9119 nice=0 sched=0/0 cgrp=default handle=27700176
01-27 17:16:22.180: I/dalvikvm(9050): | schedstat=( 6918844000 741848000 1627 ) utm=668 stm=23 core=0
01-27 17:16:22.180: I/dalvikvm(9050): at java.lang.String.<init>(String.java:~432)
01-27 17:16:22.180: I/dalvikvm(9050): at java.io.BufferedReader.readLine(BufferedReader.java:363)
01-27 17:16:22.180: I/dalvikvm(9050): at com.kittykazoo.game.Dictionary.loadWords(Dictionary.java:22)
01-27 17:16:22.180: I/dalvikvm(9050): at com.kittykazoo.gamecore.ScreenLoading.loadAssets(ScreenLoading.java:232)
01-27 17:16:22.180: I/dalvikvm(9050): at com.kittykazoo.gamecore.ScreenLoading.update(ScreenLoading.java:64)
01-27 17:16:22.180: I/dalvikvm(9050): at com.kittykazoo.framework.implementation.AndroidFastRenderView.run(AndroidFastRenderView.java:48)
01-27 17:16:22.180: I/dalvikvm(9050): at java.lang.Thread.run(Thread.java:856)
01-27 17:16:22.280: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:22.280: D/dalvikvm(9050): GC_FOR_ALLOC freed 0K, 1% free 48730K/49159K, paused 107ms
01-27 17:16:22.280: I/dalvikvm-heap(9050): Forcing collection of SoftReferences for 72-byte allocation
01-27 17:16:22.400: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:22.400: D/dalvikvm(9050): GC_BEFORE_OOM freed 0K, 1% free 48730K/49159K, paused 118ms
01-27 17:16:22.400: E/dalvikvm-heap(9050): Out of memory on a 72-byte allocation.
01-27 17:16:22.400: I/dalvikvm(9050): "Thread-1489" prio=5 tid=13 RUNNABLE
01-27 17:16:22.400: I/dalvikvm(9050): | group="main" sCount=0 dsCount=0 obj=0x417e7bd8 self=0x1a6a168
01-27 17:16:22.400: I/dalvikvm(9050): | sysTid=9119 nice=0 sched=0/0 cgrp=default handle=27700176
01-27 17:16:22.400: I/dalvikvm(9050): | schedstat=( 7142111000 746215000 1665 ) utm=690 stm=24 core=0
01-27 17:16:22.400: I/dalvikvm(9050): at java.lang.Throwable.nativeFillInStackTrace(Native Method)
01-27 17:16:22.400: I/dalvikvm(9050): at java.lang.Throwable.fillInStackTrace(Throwable.java:160)
01-27 17:16:22.400: I/dalvikvm(9050): at java.lang.Throwable.<init>(Throwable.java:83)
01-27 17:16:22.400: I/dalvikvm(9050): at java.lang.Error.<init>(Error.java:37)
01-27 17:16:22.400: I/dalvikvm(9050): at java.lang.VirtualMachineError.<init>(VirtualMachineError.java:35)
01-27 17:16:22.400: I/dalvikvm(9050): at java.lang.OutOfMemoryError.<init>(OutOfMemoryError.java:33)
01-27 17:16:22.400: I/dalvikvm(9050): at java.lang.String.<init>(String.java:-1)
01-27 17:16:22.400: I/dalvikvm(9050): at java.io.BufferedReader.readLine(BufferedReader.java:363)
01-27 17:16:22.400: I/dalvikvm(9050): at com.kittykazoo.game.Dictionary.loadWords(Dictionary.java:22)
01-27 17:16:22.400: I/dalvikvm(9050): at com.kittykazoo.gamecore.ScreenLoading.loadAssets(ScreenLoading.java:232)
01-27 17:16:22.400: I/dalvikvm(9050): at com.kittykazoo.gamecore.ScreenLoading.update(ScreenLoading.java:64)
01-27 17:16:22.400: I/dalvikvm(9050): at com.kittykazoo.framework.implementation.AndroidFastRenderView.run(AndroidFastRenderView.java:48)
01-27 17:16:22.400: I/dalvikvm(9050): at java.lang.Thread.run(Thread.java:856)
01-27 17:16:22.410: W/dalvikvm(9050): Exception thrown (Ljava/lang/OutOfMemoryError;) while throwing internal exception (Ljava/lang/OutOfMemoryError;)
01-27 17:16:22.510: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:22.510: D/dalvikvm(9050): GC_FOR_ALLOC freed <1K, 1% free 48730K/49159K, paused 106ms
01-27 17:16:22.510: I/dalvikvm-heap(9050): Forcing collection of SoftReferences for 54-byte allocation
01-27 17:16:22.630: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:22.630: D/dalvikvm(9050): GC_BEFORE_OOM freed 0K, 1% free 48730K/49159K, paused 122ms
01-27 17:16:22.630: E/dalvikvm-heap(9050): Out of memory on a 54-byte allocation.
01-27 17:16:22.630: I/dalvikvm(9050): "Thread-1489" prio=5 tid=13 RUNNABLE
01-27 17:16:22.630: I/dalvikvm(9050): | group="main" sCount=0 dsCount=0 obj=0x417e7bd8 self=0x1a6a168
01-27 17:16:22.630: I/dalvikvm(9050): | sysTid=9119 nice=0 sched=0/0 cgrp=default handle=27700176
01-27 17:16:22.630: I/dalvikvm(9050): | schedstat=( 7366692000 753065000 1725 ) utm=709 stm=27 core=0
01-27 17:16:22.630: I/dalvikvm(9050): at java.io.BufferedReader.readLine(BufferedReader.java:~422)
01-27 17:16:22.630: I/dalvikvm(9050): at com.kittykazoo.game.Dictionary.loadWords(Dictionary.java:22)
01-27 17:16:22.630: I/dalvikvm(9050): at com.kittykazoo.gamecore.ScreenLoading.loadAssets(ScreenLoading.java:232)
01-27 17:16:22.630: I/dalvikvm(9050): at com.kittykazoo.gamecore.ScreenLoading.update(ScreenLoading.java:64)
01-27 17:16:22.630: I/dalvikvm(9050): at com.kittykazoo.framework.implementation.AndroidFastRenderView.run(AndroidFastRenderView.java:48)
01-27 17:16:22.630: I/dalvikvm(9050): at java.lang.Thread.run(Thread.java:856)
01-27 17:16:22.750: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:22.750: D/dalvikvm(9050): GC_FOR_ALLOC freed 0K, 1% free 48730K/49159K, paused 112ms
01-27 17:16:22.750: I/dalvikvm-heap(9050): Forcing collection of SoftReferences for 64-byte allocation
01-27 17:16:22.870: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:22.870: D/dalvikvm(9050): GC_BEFORE_OOM freed 0K, 1% free 48730K/49159K, paused 122ms
01-27 17:16:22.870: E/dalvikvm-heap(9050): Out of memory on a 64-byte allocation.
01-27 17:16:22.870: I/dalvikvm(9050): "Thread-1489" prio=5 tid=13 RUNNABLE
01-27 17:16:22.870: I/dalvikvm(9050): | group="main" sCount=0 dsCount=0 obj=0x417e7bd8 self=0x1a6a168
01-27 17:16:22.870: I/dalvikvm(9050): | sysTid=9119 nice=0 sched=0/0 cgrp=default handle=27700176
01-27 17:16:22.870: I/dalvikvm(9050): | schedstat=( 7590841000 762536000 1798 ) utm=731 stm=28 core=1
01-27 17:16:22.870: I/dalvikvm(9050): at java.lang.Throwable.nativeFillInStackTrace(Native Method)
01-27 17:16:22.870: I/dalvikvm(9050): at java.lang.Throwable.fillInStackTrace(Throwable.java:160)
01-27 17:16:22.870: I/dalvikvm(9050): at java.lang.Throwable.<init>(Throwable.java:83)
01-27 17:16:22.870: I/dalvikvm(9050): at java.lang.Error.<init>(Error.java:37)
01-27 17:16:22.870: I/dalvikvm(9050): at java.lang.VirtualMachineError.<init>(VirtualMachineError.java:35)
01-27 17:16:22.870: I/dalvikvm(9050): at java.lang.OutOfMemoryError.<init>(OutOfMemoryError.java:33)
01-27 17:16:22.870: I/dalvikvm(9050): at java.io.BufferedReader.readLine(BufferedReader.java:-1)
01-27 17:16:22.870: I/dalvikvm(9050): at com.kittykazoo.game.Dictionary.loadWords(Dictionary.java:22)
01-27 17:16:22.870: I/dalvikvm(9050): at com.kittykazoo.gamecore.ScreenLoading.loadAssets(ScreenLoading.java:232)
01-27 17:16:22.870: I/dalvikvm(9050): at com.kittykazoo.gamecore.ScreenLoading.update(ScreenLoading.java:64)
01-27 17:16:22.870: I/dalvikvm(9050): at com.kittykazoo.framework.implementation.AndroidFastRenderView.run(AndroidFastRenderView.java:48)
01-27 17:16:22.870: I/dalvikvm(9050): at java.lang.Thread.run(Thread.java:856)
01-27 17:16:22.870: W/dalvikvm(9050): Exception thrown (Ljava/lang/OutOfMemoryError;) while throwing internal exception (Ljava/lang/OutOfMemoryError;)
01-27 17:16:22.870: W/dalvikvm(9050): Could not resolve class ref'ed in exception catch list (class index 1237, exception Ljava/lang/OutOfMemoryError;)
01-27 17:16:22.870: W/dalvikvm(9050): threadid=13: thread exiting with uncaught exception (group=0x40a391f8)
01-27 17:16:23.000: I/dalvikvm-heap(9050): Clamp target GC heap from 49.620MB to 48.000MB
01-27 17:16:23.000: D/dalvikvm(9050): GC_FOR_ALLOC freed 24K, 1% free 48706K/49159K, paused 128ms
01-27 17:16:23.000: E/AndroidRuntime(9050): FATAL EXCEPTION: Thread-1489
01-27 17:16:23.000: E/AndroidRuntime(9050): java.lang.OutOfMemoryError: [memory exhausted]
01-27 17:16:23.000: E/AndroidRuntime(9050): at dalvik.system.NativeStart.main(Native Method)
01-27 17:18:00.910: I/Process(9050): Sending signal. PID: 9050 SIG: 9
Ended up finding a workaround by using android:largeHeap="true" in the AndroidManifest.xml file.
The AndroidDev documentation says that most applications shouldn't require that, but I don't feel the least bit guilty about it -- if they're going to limit each app to 48mb of RAM with a normal sized heap then I don't see how anyone is supposed to avoid using largeHeap for anything with more than a dozen small bitmaps and some background music.
I am using FragmentActivity in my application with several Fragments. Each of these fragments hold an image and some text with animation. When user swipes on the screen, the fragment changes.
Now I have been working on this since 10 days and have tested the FragmentActivity on different devices with different Android versions. The reason that I am stuck on this from last 10 days is I am getting a crash
Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 27830 (ple.myfragexample)
Now, this error occurs only when I test the FragmentActivity on Android 4.1.2 particularly. It would run fine on Android 2.3.3, 4.0.3, 4.0.4, 4.2 and even 2.2. The error log is as below:
08-07 14:34:13.843: D/dalvikvm(27830): GC_FOR_ALLOC freed 3845K, 14% free 35407K/40903K, paused 4ms, total 14ms
08-07 14:34:13.848: I/dalvikvm-heap(27830): Grow heap (frag case) to 39.590MB for 3932176-byte allocation
08-07 14:34:13.878: D/dalvikvm(27830): GC_CONCURRENT freed 3K, 5% free 39244K/40903K, paused 11ms+4ms, total 30ms
08-07 14:34:13.928: D/dalvikvm(27830): GC_FOR_ALLOC freed 0K, 5% free 39244K/40903K, paused 16ms, total 16ms
08-07 14:34:13.928: I/dalvikvm-heap(27830): Forcing collection of SoftReferences for 8847376-byte allocation
08-07 14:34:13.953: D/dalvikvm(27830): GC_BEFORE_OOM freed 9K, 5% free 39235K/40903K, paused 24ms, total 24ms
08-07 14:34:13.953: E/dalvikvm-heap(27830): Out of memory on a 8847376-byte allocation.
08-07 14:34:13.953: I/dalvikvm(27830): "main" prio=5 tid=1 RUNNABLE
08-07 14:34:13.953: I/dalvikvm(27830): | group="main" sCount=0 dsCount=0 obj=0x41ea8508 self=0x41e989c8
08-07 14:34:13.953: I/dalvikvm(27830): | sysTid=27830 nice=0 sched=0/0 cgrp=apps handle=1074937648
08-07 14:34:13.953: I/dalvikvm(27830): | schedstat=( 2591504030 1697770606 13588 ) utm=221 stm=38 core=0
08-07 14:34:13.953: I/dalvikvm(27830): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
08-07 14:34:13.953: I/dalvikvm(27830): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:625)
08-07 14:34:13.953: I/dalvikvm(27830): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:478)
08-07 14:34:13.953: I/dalvikvm(27830): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:781)
08-07 14:34:13.953: I/dalvikvm(27830): at android.content.res.Resources.loadDrawable(Resources.java:1963)
08-07 14:34:13.953: I/dalvikvm(27830): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
08-07 14:34:13.953: I/dalvikvm(27830): at android.view.View.<init>(View.java:3449)
08-07 14:34:13.953: I/dalvikvm(27830): at android.widget.ImageView.<init>(ImageView.java:114)
08-07 14:34:13.953: I/dalvikvm(27830): at android.widget.ImageView.<init>(ImageView.java:110)
08-07 14:34:13.953: I/dalvikvm(27830): at java.lang.reflect.Constructor.constructNative(Native Method)
08-07 14:34:13.953: I/dalvikvm(27830): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
08-07 14:34:13.953: I/dalvikvm(27830): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
08-07 14:34:13.953: I/dalvikvm(27830): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
08-07 14:34:13.953: I/dalvikvm(27830): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
08-07 14:34:13.953: I/dalvikvm(27830): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
08-07 14:34:13.953: I/dalvikvm(27830): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
08-07 14:34:13.953: I/dalvikvm(27830): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
08-07 14:34:13.953: I/dalvikvm(27830): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
08-07 14:34:13.953: I/dalvikvm(27830): at com.example.myfragexample.pages.Page6.onCreateView(Page6.java:52)
08-07 14:34:13.953: I/dalvikvm(27830): at android.support.v4.app.Fragment.performCreateView(Fragment.java:1460)
08-07 14:34:13.953: I/dalvikvm(27830): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:911)
08-07 14:34:13.953: I/dalvikvm(27830): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088)
08-07 14:34:13.953: I/dalvikvm(27830): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
08-07 14:34:13.953: I/dalvikvm(27830): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
08-07 14:34:13.953: I/dalvikvm(27830): at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:429)
08-07 14:34:13.953: I/dalvikvm(27830): at android.os.Handler.handleCallback(Handler.java:615)
08-07 14:34:13.953: I/dalvikvm(27830): at android.os.Handler.dispatchMessage(Handler.java:92)
08-07 14:34:13.953: I/dalvikvm(27830): at android.os.Looper.loop(Looper.java:137)
08-07 14:34:13.953: I/dalvikvm(27830): at android.app.ActivityThread.main(ActivityThread.java:4921)
08-07 14:34:13.953: I/dalvikvm(27830): at java.lang.reflect.Method.invokeNative(Native Method)
08-07 14:34:13.953: I/dalvikvm(27830): at java.lang.reflect.Method.invoke(Method.java:511)
08-07 14:34:13.953: I/dalvikvm(27830): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
08-07 14:34:13.953: I/dalvikvm(27830): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
08-07 14:34:13.953: I/dalvikvm(27830): at dalvik.system.NativeStart.main(Native Method)
08-07 14:34:13.953: A/libc(27830): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 27830 (ple.myfragexample)
I have searched a lot over the internet and tried many thing about this, however, the working of my Fragments got smoother on devices with any other version of Android, but just on Android 4.1.2. I also tried to use Universal Image Loader, but it still crashes with Fatal signal 11. The error log I get when I am using Universal Image Loader is as below:
08-07 14:20:03.678: D/dalvikvm(27268): GC_FOR_ALLOC freed 3857K, 32% free 33002K/48455K, paused 31ms, total 34ms
08-07 14:20:03.678: I/dalvikvm-heap(27268): Grow heap (frag case) to 37.241MB for 3932176-byte allocation
08-07 14:20:03.708: D/dalvikvm(27268): GC_FOR_ALLOC freed 5K, 24% free 36837K/48455K, paused 28ms, total 28ms
08-07 14:20:03.738: D/dalvikvm(27268): GC_CONCURRENT freed <1K, 24% free 36837K/48455K, paused 11ms+2ms, total 30ms
08-07 14:20:03.848: D/dalvikvm(27268): GC_FOR_ALLOC freed <1K, 24% free 36837K/48455K, paused 17ms, total 17ms
08-07 14:20:03.848: I/dalvikvm-heap(27268): Forcing collection of SoftReferences for 8847376-byte allocation
08-07 14:20:03.883: D/dalvikvm(27268): GC_BEFORE_OOM freed 9K, 24% free 36828K/48455K, paused 32ms, total 35ms
08-07 14:20:03.883: E/dalvikvm-heap(27268): Out of memory on a 8847376-byte allocation.
08-07 14:20:03.888: I/dalvikvm(27268): "pool-1-thread-1" prio=4 tid=12 RUNNABLE
08-07 14:20:03.888: I/dalvikvm(27268): | group="main" sCount=0 dsCount=0 obj=0x4293af60 self=0x4f6c9470
08-07 14:20:03.888: I/dalvikvm(27268): | sysTid=27283 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=1098606736
08-07 14:20:03.888: I/dalvikvm(27268): | schedstat=( 2735922613 2106917058 1146 ) utm=266 stm=7 core=0
08-07 14:20:03.888: I/dalvikvm(27268): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
08-07 14:20:03.888: I/dalvikvm(27268): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:625)
08-07 14:20:03.888: I/dalvikvm(27268): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:478)
08-07 14:20:03.888: I/dalvikvm(27268): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:781)
08-07 14:20:03.888: I/dalvikvm(27268): at android.content.res.Resources.loadDrawable(Resources.java:1963)
08-07 14:20:03.888: I/dalvikvm(27268): at android.content.res.Resources.getDrawable(Resources.java:672)
08-07 14:20:03.888: I/dalvikvm(27268): at com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStreamFromDrawable(BaseImageDownloader.java:184)
08-07 14:20:03.888: I/dalvikvm(27268): at com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStream(BaseImageDownloader.java:84)
08-07 14:20:03.888: I/dalvikvm(27268): at com.nostra13.universalimageloader.core.decode.BaseImageDecoder.getImageStream(BaseImageDecoder.java:82)
08-07 14:20:03.888: I/dalvikvm(27268): at com.nostra13.universalimageloader.core.decode.BaseImageDecoder.decode(BaseImageDecoder.java:68)
08-07 14:20:03.888: I/dalvikvm(27268): at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.decodeImage(LoadAndDisplayImageTask.java:284)
08-07 14:20:03.888: I/dalvikvm(27268): at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.tryLoadBitmap(LoadAndDisplayImageTask.java:243)
08-07 14:20:03.888: I/dalvikvm(27268): at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.run(LoadAndDisplayImageTask.java:125)
08-07 14:20:03.888: I/dalvikvm(27268): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
08-07 14:20:03.888: I/dalvikvm(27268): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
08-07 14:20:03.888: I/dalvikvm(27268): at java.lang.Thread.run(Thread.java:856)
08-07 14:20:03.888: A/libc(27268): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 27283 (pool-1-thread-1)
Now, I know there are lots of questions with Fatal signal 11 on here too, but I am concerned and confused as I am getting this crash only on Android 4.1.2 and not on any other Android versions.
My issue is solved now. I just got my images re-sized from my Graphics team. Previously I was using 1280x768 resolution images but I got them scaled down to 800x480 and the crash is gone. Thanks for all the suggestions though.
Also, I think Jelly Bean (4.x) has enhanced UI and so, it occupies more memory for handling the UI itself than the lower versions of Android, and that's why it was not able to manage handling(scaling down) the larger images.
Have a look at my question:
Strange crash drawing on canvas on Android 4.0.3. A/libc: Fatal signal 11 (SIGSEGV)
maybe it's the same problem. The issue arises when I try to use a small number for stroke or others Paint properties.
setStrokeWidth(0.007f);
Never solved, I suggest to scale the Canvas and use bigger numbers.
I'm writing an Android app. It has two pages. The second page is supposed to be a page full of image buttons. But when I run my app in the emulator and go to the second page, the page is not displayed. Why?
Here's an error I get:
Android logcat Text :Fatal signal 11(SIGSEGV) at 0X00000000 (code==1) ,thread 614(com.s
THIS IS THE ENTIRE LOGCAT
: D/gralloc_goldfish(614): Emulator without GPU emulation detected.
01-14 09:08:14.554: D/dalvikvm(614): GC_FOR_ALLOC freed 89K, 3% free 8141K/8327K, paused 33ms, total 35ms
01-14 09:08:14.584: I/dalvikvm-heap(614): Grow heap (frag case) to 10.998MB for 3145744-byte allocation
01-14 09:08:14.744: D/dalvikvm(614): GC_CONCURRENT freed 4K, 3% free 11209K/11463K, paused 105ms+15ms, total 160ms
01-14 09:08:15.054: D/dalvikvm(614): GC_FOR_ALLOC freed 0K, 3% free 11209K/11463K, paused 22ms, total 22ms
01-14 09:08:15.104: I/dalvikvm-heap(614): Grow heap (frag case) to 17.744MB for 7077904-byte allocation
01-14 09:08:15.254: D/dalvikvm(614): GC_CONCURRENT freed 0K, 2% free 18121K/18439K, paused 97ms+6ms, total 157ms
01-14 09:08:15.424: D/dalvikvm(614): GC_FOR_ALLOC freed 3072K, 19% free 15050K/18439K, paused 27ms, total 27ms
01-14 09:08:15.424: I/dalvikvm-heap(614): Grow heap (frag case) to 17.745MB for 3145744-byte allocation
01-14 09:08:15.574: D/dalvikvm(614): GC_CONCURRENT freed <1K, 2% free 18122K/18439K, paused 102ms+15ms, total 149ms
01-14 09:08:15.904: D/dalvikvm(614): GC_FOR_ALLOC freed 0K, 2% free 18122K/18439K, paused 27ms, total 27ms
01-14 09:08:15.954: I/dalvikvm-heap(614): Grow heap (frag case) to 24.495MB for 7077904-byte allocation
01-14 09:08:16.094: D/dalvikvm(614): GC_CONCURRENT freed 0K, 2% free 25034K/25415K, paused 76ms+6ms, total 140ms
01-14 09:08:16.304: D/dalvikvm(614): GC_FOR_ALLOC freed 3072K, 14% free 21964K/25415K, paused 32ms, total 33ms
01-14 09:08:16.314: I/dalvikvm-heap(614): Grow heap (frag case) to 24.498MB for 3145744-byte allocation
01-14 09:08:16.484: D/dalvikvm(614): GC_CONCURRENT freed <1K, 2% free 25036K/25415K, paused 109ms+16ms, total 170ms
01-14 09:08:16.764: D/dalvikvm(614): GC_FOR_ALLOC freed 0K, 2% free 25036K/25415K, paused 30ms, total 30ms
01-14 09:08:16.814: I/dalvikvm-heap(614): Grow heap (frag case) to 31.248MB for 7077904-byte allocation
01-14 09:08:16.994: D/dalvikvm(614): GC_CONCURRENT freed 0K, 2% free 31948K/32391K, paused 99ms+7ms, total 180ms
01-14 09:08:17.145: D/dalvikvm(614): GC_FOR_ALLOC freed 3072K, 11% free 28878K/32391K, paused 37ms, total 37ms
01-14 09:08:17.154: I/dalvikvm-heap(614): Grow heap (frag case) to 31.249MB for 3145744-byte allocation
01-14 09:08:17.314: D/dalvikvm(614): GC_CONCURRENT freed <1K, 2% free 31950K/32391K, paused 82ms+18ms, total 161ms
01-14 09:08:17.624: D/dalvikvm(614): GC_FOR_ALLOC freed 0K, 2% free 31950K/32391K, paused 41ms, total 41ms
01-14 09:08:17.674: I/dalvikvm-heap(614): Grow heap (frag case) to 37.999MB for 7077904-byte allocation
01-14 09:08:17.874: D/dalvikvm(614): GC_CONCURRENT freed 0K, 2% free 38862K/39367K, paused 108ms+8ms, total 204ms
01-14 09:08:18.024: D/dalvikvm(614): GC_FOR_ALLOC freed 3072K, 10% free 35791K/39367K, paused 41ms, total 42ms
01-14 09:08:18.024: I/dalvikvm-heap(614): Grow heap (frag case) to 38.000MB for 3145744-byte allocation
01-14 09:08:18.184: D/dalvikvm(614): GC_CONCURRENT freed <1K, 2% free 38863K/39367K, paused 73ms+20ms, total 157ms
01-14 09:08:18.514: D/dalvikvm(614): GC_FOR_ALLOC freed 0K, 2% free 38863K/39367K, paused 40ms, total 40ms
01-14 09:08:18.564: I/dalvikvm-heap(614): Grow heap (frag case) to 44.750MB for 7077904-byte allocation
01-14 09:08:18.794: D/dalvikvm(614): GC_CONCURRENT freed 0K, 2% free 45775K/46343K, paused 92ms+21ms, total 228ms
01-14 09:08:18.954: D/dalvikvm(614): GC_FOR_ALLOC freed 3072K, 8% free 42704K/46343K, paused 43ms, total 44ms
01-14 09:08:18.954: I/dalvikvm-heap(614): Grow heap (frag case) to 44.751MB for 3145744-byte allocation
01-14 09:08:19.114: D/dalvikvm(614): GC_CONCURRENT freed <1K, 2% free 45776K/46343K, paused 74ms+7ms, total 162ms
01-14 09:08:19.445: D/dalvikvm(614): GC_FOR_ALLOC freed 0K, 2% free 45776K/46343K, paused 60ms, total 60ms
01-14 09:08:19.445: I/dalvikvm-heap(614): Forcing collection of SoftReferences for 7077904-byte allocation
01-14 09:08:19.875: D/dalvikvm(614): GC_BEFORE_OOM freed 9K, 2% free 45767K/46343K, paused 426ms, total 427ms
01-14 09:08:19.875: E/dalvikvm-heap(614): Out of memory on a 7077904-byte allocation.
01-14 09:08:19.875: I/dalvikvm(614): "main" prio=5 tid=1 RUNNABLE
01-14 09:08:19.875: I/dalvikvm(614): | group="main" sCount=0 dsCount=0 obj=0x40a14568 self=0x2a00b9e0
01-14 09:08:19.875: I/dalvikvm(614): | sysTid=614 nice=0 sched=0/0 cgrp=apps handle=1073870640
01-14 09:08:19.885: I/dalvikvm(614): | schedstat=( 3996873888 1969503221 492 ) utm=351 stm=48 core=0
01-14 09:08:19.885: I/dalvikvm(614): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
01-14 09:08:19.885: I/dalvikvm(614): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:500)
01-14 09:08:19.885: I/dalvikvm(614): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:353)
01-14 09:08:19.885: I/dalvikvm(614): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:781)
01-14 09:08:19.885: I/dalvikvm(614): at android.content.res.Resources.loadDrawable(Resources.java:1930)
01-14 09:08:19.885: I/dalvikvm(614): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
01-14 09:08:19.894: I/dalvikvm(614): at android.widget.ImageView.<init>(ImageView.java:120)
01-14 09:08:19.894: I/dalvikvm(614): at android.widget.ImageView.<init>(ImageView.java:110)
01-14 09:08:19.904: I/dalvikvm(614): at java.lang.reflect.Constructor.constructNative(Native Method)
01-14 09:08:19.904: I/dalvikvm(614): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
01-14 09:08:19.904: I/dalvikvm(614): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
01-14 09:08:19.904: I/dalvikvm(614): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
01-14 09:08:19.904: I/dalvikvm(614): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
01-14 09:08:19.904: I/dalvikvm(614): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
01-14 09:08:19.904: I/dalvikvm(614): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
01-14 09:08:19.904: I/dalvikvm(614): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
01-14 09:08:19.904: I/dalvikvm(614): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
01-14 09:08:19.904: I/dalvikvm(614): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
01-14 09:08:19.904: I/dalvikvm(614): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
01-14 09:08:19.904: I/dalvikvm(614): at android.app.Activity.setContentView(Activity.java:1867)
01-14 09:08:19.904: I/dalvikvm(614): at com.sgs.First.onCreate(First.java:13)
01-14 09:08:19.904: I/dalvikvm(614): at android.app.Activity.performCreate(Activity.java:5008)
01-14 09:08:19.904: I/dalvikvm(614): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
01-14 09:08:19.904: I/dalvikvm(614): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
01-14 09:08:19.904: I/dalvikvm(614): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
01-14 09:08:19.904: I/dalvikvm(614): at android.app.ActivityThread.access$600(ActivityThread.java:130)
01-14 09:08:19.904: I/dalvikvm(614): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
01-14 09:08:19.904: I/dalvikvm(614): at android.os.Handler.dispatchMessage(Handler.java:99)
01-14 09:08:19.904: I/dalvikvm(614): at android.os.Looper.loop(Looper.java:137)
01-14 09:08:19.904: I/dalvikvm(614): at android.app.ActivityThread.main(ActivityThread.java:4745)
01-14 09:08:19.904: I/dalvikvm(614): at java.lang.reflect.Method.invokeNative(Native Method)
01-14 09:08:19.904: I/dalvikvm(614): at java.lang.reflect.Method.invoke(Method.java:511)
01-14 09:08:19.904: I/dalvikvm(614): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
01-14 09:08:19.914: I/dalvikvm(614): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
01-14 09:08:19.914: I/dalvikvm(614): at dalvik.system.NativeStart.main(Native Method)
01-14 09:08:19.930: A/libc(614): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 614 (com.sgs)
THIS IS THE XML CODE
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imageButton1"
android:layout_width="160dp"
android:layout_height="100dp"
android:src="#drawable/c" />
<ImageView
android:id="#+id/imageButton2"
android:layout_width="160dp"
android:layout_height="100dp"
android:src="#drawable/d" />
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="300dp"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imageButton3"
android:layout_width="80dp"
android:layout_height="300dp"
android:src="#drawable/e" />
<ImageView
android:id="#+id/imageButton4"
android:layout_width="160dp"
android:layout_height="300dp"
android:src="#drawable/g" />
<ImageView
android:id="#+id/imageButton5"
android:layout_width="80dp"
android:layout_height="300dp"
android:src="#drawable/f" />
</LinearLayout>
<ImageView
android:id="#+id/imageButton6"
android:layout_width="320dp"
android:layout_height="100dp"
android:src="#drawable/h" />
</LinearLayout>
THIS IS THE CORRESPONDING JAVA FILE
package com.sgs;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
public class First extends Activity implements OnClickListener {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.first);
ImageView image1 = (ImageView) findViewById(R.id.imageButton1);
ImageView image2 = (ImageView) findViewById(R.id.imageButton2);
ImageView image3 = (ImageView) findViewById(R.id.imageButton3);
ImageView image4 = (ImageView) findViewById(R.id.imageButton4);
ImageView image5 = (ImageView) findViewById(R.id.imageButton5);
image1.setOnClickListener(this);
image2.setOnClickListener(this);
image3.setOnClickListener(this);
image4.setOnClickListener(this);
image5.setOnClickListener(this);
}
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()){
case R.id.imageButton1:
}
}
}
From the log you can see an out of memory error when an image is beeing decoded:
01-14 09:08:19.875: E/dalvikvm-heap(614): Out of memory on a 7077904-byte allocation.
Maybe the images used (by mistake) are to large for the memory allocated by you emulator device profile. You could try increasing the heap size of the device (Window-->AVD Manager-->Virtual Devices-->Edit : Hardware properties)
here is my error log please help?
I am a newbie to android and this is my first app
package gaurav.rapp.swamiji;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageSwitcher;
import android.widget.ImageView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ViewSwitcher.ViewFactory;
public class BeWithSwamijiActivity extends Activity implements ViewFactory {
Integer pics[]={R.drawable.img1,R.drawable.img2,R.drawable.img3,R.drawable.img4,R.drawable.img5,R.drawable.img6,R.drawable.img7,R.drawable.img8,R.drawable.img9,R.drawable.img10,R.drawable.img11,R.drawable.img12,R.drawable.img13,R.drawable.img14,R.drawable.img15,R.drawable.img16,R.drawable.img17};
ImageSwitcher iSwitcher;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
iSwitcher = (ImageSwitcher) findViewById(R.id.ImageSwitcher01);
iSwitcher.setFactory(this);
iSwitcher.setInAnimation(AnimationUtils.loadAnimation(this,
android.R.anim.fade_in));
iSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this,
android.R.anim.fade_out));
Gallery gallery = (Gallery) findViewById(R.id.Gallery01);
gallery.setAdapter(new ImageAdapter(this));
gallery.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
iSwitcher.setImageResource(pics[arg2]);
}
});
}
public class ImageAdapter extends BaseAdapter {
private Context ctx;
public ImageAdapter(Context c) {
ctx = c;
}
#Override
public int getCount() {
return pics.length;
}
#Override
public Object getItem(int arg0) {
return arg0;
}
#Override
public long getItemId(int arg0) {
return arg0;
}
#Override
public View getView(int arg0, View arg1, ViewGroup arg2) {
ImageView iView = new ImageView(ctx);
iView.setImageResource(pics[arg0]);
iView.setScaleType(ImageView.ScaleType.FIT_XY);
iView.setLayoutParams(new Gallery.LayoutParams(150, 150));
return iView;
}
}
#Override
public View makeView() {
ImageView iView=new ImageView(this);
iView.setScaleType(ImageView.ScaleType.FIT_CENTER);
iView.setLayoutParams(new ImageSwitcher.LayoutParams(
LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
iView.setBackgroundColor(0xFF000000);
return iView;
}
}
Log
05-13 21:58:39.107: I/Process(397): Sending signal. PID: 397 SIG: 9
05-13 21:58:45.517: D/dalvikvm(409): GC_FOR_ALLOC freed 43K, 4% free 6362K/6595K, paused 75ms
05-13 21:58:45.587: I/dalvikvm-heap(409): Grow heap (frag case) to 10.624MB for 4566704-byte allocation
05-13 21:58:45.697: D/dalvikvm(409): GC_FOR_ALLOC freed 1K, 3% free 10820K/11079K, paused 86ms
05-13 21:58:45.887: D/dalvikvm(409): GC_CONCURRENT freed <1K, 3% free 10820K/11079K, paused 25ms+3ms
05-13 21:58:46.427: D/dalvikvm(409): GC_FOR_ALLOC freed <1K, 3% free 10820K/11079K, paused 112ms
05-13 21:58:46.547: I/dalvikvm-heap(409): Grow heap (frag case) to 18.362MB for 8114772-byte allocation
05-13 21:58:46.839: D/dalvikvm(409): GC_FOR_ALLOC freed 0K, 2% free 18745K/19015K, paused 72ms
05-13 21:58:47.057: D/dalvikvm(409): GC_CONCURRENT freed 0K, 2% free 18745K/19015K, paused 4ms+16ms
05-13 21:58:47.680: D/dalvikvm(409): GC_FOR_ALLOC freed 5051K, 26% free 15340K/20679K, paused 72ms
05-13 21:58:47.889: D/dalvikvm(409): GC_FOR_ALLOC freed <1K, 21% free 16537K/20679K, paused 71ms
05-13 21:58:47.889: I/dalvikvm-heap(409): Grow heap (frag case) to 18.284MB for 2179600-byte allocation
05-13 21:58:48.037: D/dalvikvm(409): GC_FOR_ALLOC freed 0K, 10% free 18666K/20679K, paused 75ms
05-13 21:58:48.307: D/dalvikvm(409): GC_CONCURRENT freed 0K, 10% free 18666K/20679K, paused 5ms+3ms
05-13 21:58:48.511: D/dalvikvm(409): GC_FOR_ALLOC freed 1197K, 11% free 18425K/20679K, paused 73ms
05-13 21:58:48.530: I/dalvikvm-heap(409): Grow heap (frag case) to 19.705MB for 1735988-byte allocation
05-13 21:58:48.681: D/dalvikvm(409): GC_FOR_ALLOC freed 0K, 11% free 20120K/22407K, paused 76ms
05-13 21:59:09.187: D/dalvikvm(409): GC_FOR_ALLOC freed 961K, 13% free 19660K/22407K, paused 75ms
05-13 21:59:11.737: D/dalvikvm(409): GC_FOR_ALLOC freed 678K, 10% free 20385K/22407K, paused 143ms
05-13 21:59:11.797: I/dalvikvm-heap(409): Grow heap (frag case) to 24.518MB for 4776976-byte allocation
05-13 21:59:11.971: D/dalvikvm(409): GC_FOR_ALLOC freed <1K, 8% free 25049K/27079K, paused 85ms
05-13 21:59:12.117: D/dalvikvm(409): GC_CONCURRENT freed <1K, 8% free 25049K/27079K, paused 4ms+3ms
05-13 21:59:12.327: D/dalvikvm(409): GC_FOR_ALLOC freed <1K, 8% free 25049K/27079K, paused 93ms
05-13 21:59:12.437: I/dalvikvm-heap(409): Grow heap (frag case) to 32.619MB for 8494048-byte allocation
05-13 21:59:12.589: D/dalvikvm(409): GC_FOR_ALLOC freed 0K, 6% free 33344K/35399K, paused 82ms
05-13 21:59:12.877: D/dalvikvm(409): GC_CONCURRENT freed 0K, 6% free 33345K/35399K, paused 5ms+4ms
05-13 21:59:29.208: D/dalvikvm(409): GC_FOR_ALLOC freed 4862K, 17% free 29383K/35399K, paused 84ms
05-13 21:59:31.130: D/dalvikvm(409): GC_FOR_ALLOC freed 353K, 13% free 30855K/35399K, paused 84ms
05-13 21:59:31.137: I/dalvikvm-heap(409): Grow heap (frag case) to 32.266MB for 2179600-byte allocation
05-13 21:59:31.287: D/dalvikvm(409): GC_FOR_ALLOC freed <1K, 7% free 32983K/35399K, paused 82ms
05-13 21:59:31.538: D/dalvikvm(409): GC_CONCURRENT freed 0K, 7% free 32983K/35399K, paused 5ms+4ms
05-13 21:59:31.647: D/dalvikvm(409): GC_FOR_ALLOC freed 1549K, 12% free 31435K/35399K, paused 92ms
05-13 21:59:31.692: I/dalvikvm-heap(409): Grow heap (frag case) to 33.028MB for 2384216-byte allocation
05-13 21:59:31.880: D/dalvikvm(409): GC_FOR_ALLOC freed 0K, 11% free 33764K/37767K, paused 100ms
05-13 21:59:32.057: D/dalvikvm(409): GC_CONCURRENT freed <1K, 11% free 33764K/37767K, paused 4ms+4ms
05-13 21:59:32.307: D/dalvikvm(409): GC_FOR_ALLOC freed <1K, 11% free 33764K/37767K, paused 108ms
05-13 21:59:32.377: I/dalvikvm-heap(409): Grow heap (frag case) to 37.073MB for 4241380-byte allocation
05-13 21:59:32.547: D/dalvikvm(409): GC_FOR_ALLOC freed 0K, 10% free 37906K/41927K, paused 97ms
05-13 21:59:32.797: D/dalvikvm(409): GC_CONCURRENT freed 0K, 10% free 37906K/41927K, paused 4ms+14ms
05-13 21:59:34.747: D/dalvikvm(409): GC_FOR_ALLOC freed 2329K, 13% free 36533K/41927K, paused 98ms
05-13 21:59:35.037: D/dalvikvm(409): GC_CONCURRENT freed 1304K, 12% free 37261K/41927K, paused 4ms+4ms
05-13 21:59:42.547: D/dalvikvm(409): GC_FOR_ALLOC freed 337K, 11% free 37524K/41927K, paused 88ms
05-13 21:59:42.607: I/dalvikvm-heap(409): Grow heap (frag case) to 41.255MB for 4776976-byte allocation
05-13 21:59:42.801: D/dalvikvm(409): GC_FOR_ALLOC freed <1K, 10% free 42188K/46599K, paused 104ms
05-13 21:59:43.021: D/dalvikvm(409): GC_CONCURRENT freed <1K, 10% free 42188K/46599K, paused 4ms+4ms
05-13 21:59:43.180: D/dalvikvm(409): GC_FOR_ALLOC freed <1K, 10% free 42189K/46599K, paused 98ms
05-13 21:59:43.180: I/dalvikvm-heap(409): Forcing collection of SoftReferences for 8494048-byte allocation
05-13 21:59:43.327: D/dalvikvm(409): GC_BEFORE_OOM freed 8K, 10% free 42180K/46599K, paused 143ms
05-13 21:59:43.327: E/dalvikvm-heap(409): Out of memory on a 8494048-byte allocation.
05-13 21:59:43.337: I/dalvikvm(409): "main" prio=5 tid=1 RUNNABLE
05-13 21:59:43.337: I/dalvikvm(409): | group="main" sCount=0 dsCount=0 obj=0x4001b5c8 self=0x125d8
05-13 21:59:43.337: I/dalvikvm(409): | sysTid=409 nice=0 sched=0/0 cgrp=default handle=-1342913432
05-13 21:59:43.337: I/dalvikvm(409): | schedstat=( 10690152881 5424008534 597 ) utm=864 stm=205 core=0
05-13 21:59:43.337: I/dalvikvm(409): at android.graphics.Bitmap.nativeCreate(Native Method)
05-13 21:59:43.337: I/dalvikvm(409): at android.graphics.Bitmap.createBitmap(Bitmap.java:604)
05-13 21:59:43.337: I/dalvikvm(409): at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
05-13 21:59:43.337: I/dalvikvm(409): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
05-13 21:59:43.337: I/dalvikvm(409): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:524)
05-13 21:59:43.347: I/dalvikvm(409): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:499)
05-13 21:59:43.347: I/dalvikvm(409): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:351)
05-13 21:59:43.347: I/dalvikvm(409): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:738)
05-13 21:59:43.347: I/dalvikvm(409): at android.content.res.Resources.loadDrawable(Resources.java:1918)
05-13 21:59:43.347: I/dalvikvm(409): at android.content.res.Resources.getDrawable(Resources.java:655)
05-13 21:59:43.357: I/dalvikvm(409): at android.widget.ImageView.resolveUri(ImageView.java:510)
05-13 21:59:43.357: I/dalvikvm(409): at android.widget.ImageView.setImageResource(ImageView.java:289)
05-13 21:59:43.357: I/dalvikvm(409): at android.widget.ImageSwitcher.setImageResource(ImageSwitcher.java:41)
05-13 21:59:43.357: I/dalvikvm(409): at gaurav.rapp.swamiji.BeWithSwamijiActivity$1.onItemClick(BeWithSwamijiActivity.java:39)
05-13 21:59:43.357: I/dalvikvm(409): at android.widget.AdapterView.performItemClick(AdapterView.java:282)
05-13 21:59:43.357: I/dalvikvm(409): at android.widget.Gallery.onSingleTapUp(Gallery.java:867)
05-13 21:59:43.357: I/dalvikvm(409): at android.view.GestureDetector.onTouchEvent(GestureDetector.java:557)
05-13 21:59:43.357: I/dalvikvm(409): at android.widget.Gallery.onTouchEvent(Gallery.java:842)
05-13 21:59:43.377: I/dalvikvm(409): at android.view.View.dispatchTouchEvent(View.java:4609)
05-13 21:59:43.377: I/dalvikvm(409): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1554)
05-13 21:59:43.377: I/dalvikvm(409): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1320)
05-13 21:59:43.377: I/dalvikvm(409): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
05-13 21:59:43.387: I/dalvikvm(409): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
05-13 21:59:43.387: I/dalvikvm(409): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
05-13 21:59:43.387: I/dalvikvm(409): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
05-13 21:59:43.387: I/dalvikvm(409): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
05-13 21:59:43.387: I/dalvikvm(409): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
05-13 21:59:43.387: I/dalvikvm(409): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
05-13 21:59:43.387: I/dalvikvm(409): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
05-13 21:59:43.387: I/dalvikvm(409): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1709)
05-13 21:59:43.407: I/dalvikvm(409): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1264)
05-13 21:59:43.407: I/dalvikvm(409): at android.app.Activity.dispatchTouchEvent(Activity.java:2315)
05-13 21:59:43.407: I/dalvikvm(409): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1682)
05-13 21:59:43.417: I/dalvikvm(409): at android.view.View.dispatchPointerEvent(View.java:4677)
05-13 21:59:43.417: I/dalvikvm(409): at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2392)
05-13 21:59:43.417: I/dalvikvm(409): at android.view.ViewRoot.handleMessage(ViewRoot.java:2054)
05-13 21:59:43.417: I/dalvikvm(409): at android.os.Handler.dispatchMessage(Handler.java:99)
05-13 21:59:43.417: I/dalvikvm(409): at android.os.Looper.loop(Looper.java:132)
05-13 21:59:43.417: I/dalvikvm(409): at android.app.ActivityThread.main(ActivityThread.java:4123)
05-13 21:59:43.417: I/dalvikvm(409): at java.lang.reflect.Method.invokeNative(Native Method)
05-13 21:59:43.417: I/dalvikvm(409): at java.lang.reflect.Method.invoke(Method.java:491)
05-13 21:59:43.417: I/dalvikvm(409): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
05-13 21:59:43.417: I/dalvikvm(409): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
05-13 21:59:43.417: I/dalvikvm(409): at dalvik.system.NativeStart.main(Native Method)
05-13 21:59:43.417: D/AndroidRuntime(409): Shutting down VM
05-13 21:59:43.417: W/dalvikvm(409): threadid=1: thread exiting with uncaught exception (group=0x40014760)
05-13 21:59:43.467: E/AndroidRuntime(409): FATAL EXCEPTION: main
05-13 21:59:43.467: E/AndroidRuntime(409): java.lang.OutOfMemoryError
05-13 21:59:43.467: E/AndroidRuntime(409): at android.graphics.Bitmap.nativeCreate(Native Method)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.graphics.Bitmap.createBitmap(Bitmap.java:604)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:524)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:499)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:351)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:738)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.content.res.Resources.loadDrawable(Resources.java:1918)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.content.res.Resources.getDrawable(Resources.java:655)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.widget.ImageView.resolveUri(ImageView.java:510)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.widget.ImageView.setImageResource(ImageView.java:289)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.widget.ImageSwitcher.setImageResource(ImageSwitcher.java:41)
05-13 21:59:43.467: E/AndroidRuntime(409): at gaurav.rapp.swamiji.BeWithSwamijiActivity$1.onItemClick(BeWithSwamijiActivity.java:39)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.widget.AdapterView.performItemClick(AdapterView.java:282)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.widget.Gallery.onSingleTapUp(Gallery.java:867)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.GestureDetector.onTouchEvent(GestureDetector.java:557)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.widget.Gallery.onTouchEvent(Gallery.java:842)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.View.dispatchTouchEvent(View.java:4609)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1554)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1320)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
05-13 21:59:43.467: E/AndroidRuntime(409): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1709)
05-13 21:59:43.467: E/AndroidRuntime(409): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1264)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.app.Activity.dispatchTouchEvent(Activity.java:2315)
05-13 21:59:43.467: E/AndroidRuntime(409): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1682)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.View.dispatchPointerEvent(View.java:4677)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2392)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewRoot.handleMessage(ViewRoot.java:2054)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.os.Handler.dispatchMessage(Handler.java:99)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.os.Looper.loop(Looper.java:132)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.app.ActivityThread.main(ActivityThread.java:4123)
05-13 21:59:43.467: E/AndroidRuntime(409): at java.lang.reflect.Method.invokeNative(Native Method)
05-13 21:59:43.467: E/AndroidRuntime(409): at java.lang.reflect.Method.invoke(Method.java:491)
05-13 21:59:43.467: E/AndroidRuntime(409): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
05-13 21:59:43.467: E/AndroidRuntime(409): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
05-13 21:59:43.467: E/AndroidRuntime(409): at dalvik.system.NativeStart.main(Native Method)
05-13 21:59:46.117: I/Process(409): Sending signal. PID: 409 SIG: 9
Out of memory on a 8494048-byte allocation.
Don't try to load 8MB bitmaps! Resize your assets to something more appropriate, or look at BitmapFactory.Options to downscale whatever it is you are trying to load.
I'm currently try to run some opencv filters (i.e find egde, Median, ...) on images which are stored in the image gallery folder.
But I get error for loading image. My device is galaxy tab 10.1 with android 3.2, my opencv - API level 8.
I have the following source on a Button:
#Override
public void onClick(View v) {
Bitmap myBitmap = BitmapFactory.decodeFile("/sdcard/image1.jpg");
Bitmap myBitmap32 = myBitmap.copy(Bitmap.Config.ARGB_8888, true);
Mat pic1 = Utils.bitmapToMat(myBitmap32);
}
Here is LogCat:
02-07 12:31:27.290: I/System.out(16522): Not a DRM File, opening notmally
02-07 12:31:27.290: I/System.out(16522): buffer returned
02-07 12:31:27.310: D/dalvikvm(16522): GC_FOR_ALLOC freed 11K, 21% free 6975K/8775K, paused 19ms
02-07 12:31:27.320: I/dalvikvm-heap(16522): Grow heap (frag case) to 12.918MB for 6291472-byte allocation
02-07 12:31:27.340: D/dalvikvm(16522): GC_FOR_ALLOC freed <1K, 13% free 13119K/14983K, paused 19ms
02-07 12:31:27.380: D/dalvikvm(16522): GC_CONCURRENT freed 0K, 13% free 13119K/14983K, paused 2ms+2ms
02-07 12:31:27.710: D/dalvikvm(16522): GC_FOR_ALLOC freed 55K, 13% free 13063K/14983K, paused 20ms
02-07 12:31:27.730: I/dalvikvm-heap(16522): Grow heap (frag case) to 24.864MB for 12582928-byte allocation
02-07 12:31:27.780: D/dalvikvm(16522): GC_FOR_ALLOC freed 0K, 8% free 25351K/27335K, paused 21ms
02-07 12:31:27.830: D/dalvikvm(16522): GC_CONCURRENT freed <1K, 8% free 25351K/27335K, paused 2ms+3ms
02-07 12:31:27.890: W/dalvikvm(16522): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lorg/opencv/android/Utils;
02-07 12:31:27.890: D/AndroidRuntime(16522): Shutting down VM
02-07 12:31:27.890: W/dalvikvm(16522): threadid=1: thread exiting with uncaught exception (group=0x400fc760)
02-07 12:31:27.890: E/AndroidRuntime(16522): FATAL EXCEPTION: main
02-07 12:31:27.890: E/AndroidRuntime(16522): java.lang.ExceptionInInitializerError
02-07 12:31:27.890: E/AndroidRuntime(16522): at photo.klu.PhotoKLUActivity$1.onClick(PhotoKLUActivity.java:82)
02-07 12:31:27.890: E/AndroidRuntime(16522): at android.view.View.performClick(View.java:3127)
02-07 12:31:27.890: E/AndroidRuntime(16522): at android.view.View$PerformClick.run(View.java:12025)
02-07 12:31:27.890: E/AndroidRuntime(16522): at android.os.Handler.handleCallback(Handler.java:587)
02-07 12:31:27.890: E/AndroidRuntime(16522): at android.os.Handler.dispatchMessage(Handler.java:92)
02-07 12:31:27.890: E/AndroidRuntime(16522): at android.os.Looper.loop(Looper.java:132)
02-07 12:31:27.890: E/AndroidRuntime(16522): at android.app.ActivityThread.main(ActivityThread.java:4126)
02-07 12:31:27.890: E/AndroidRuntime(16522): at java.lang.reflect.Method.invokeNative(Native Method)
02-07 12:31:27.890: E/AndroidRuntime(16522): at java.lang.reflect.Method.invoke(Method.java:491)
02-07 12:31:27.890: E/AndroidRuntime(16522): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
02-07 12:31:27.890: E/AndroidRuntime(16522): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
02-07 12:31:27.890: E/AndroidRuntime(16522): at dalvik.system.NativeStart.main(Native Method)
02-07 12:31:27.890: E/AndroidRuntime(16522): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load opencv_java: findLibrary returned null
02-07 12:31:27.890: E/AndroidRuntime(16522): at java.lang.Runtime.loadLibrary(Runtime.java:425)
02-07 12:31:27.890: E/AndroidRuntime(16522): at java.lang.System.loadLibrary(System.java:554)
02-07 12:31:27.890: E/AndroidRuntime(16522): at org.opencv.android.Utils.<clinit>(Utils.java:86)
02-07 12:31:27.890: E/AndroidRuntime(16522): ... 12 more
02-07 12:31:30.010: I/dalvikvm(16522): threadid=4: reacting to signal 3
02-07 12:31:30.010: I/dalvikvm(16522): Wrote stack traces to '/data/anr/traces.txt'
02-07 12:31:37.470: I/Process(16522): Sending signal. PID: 16522 SIG: 9
Any ideas?
Thank you.
The openCV library is not attached to your application. Please do the following (i assume that the openCV library is imported to your workspace). On Package Explorer > Right click on the application project > properties > under Library click Add > select openCV Be sure that on Java Build Path you don't have anything related to openCV