Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 32140

mXX picture mXX · Jun 20, 2013 · Viewed 47.3k times · Source

50% of the time when running my app I'm getting this error

06-20 12:56:51.183: A/libc(32140): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 32140 (example.www)

I just have to reopen the app and then it works. But I don't know why I'm getting this error and the app crashes. I'm working with big images with dimensions, almost 1200x1200px and setting that as a background. I also use that image as a bitmap for some other activities as background. Also doing some calls to a server and getting JSON data back. Hope I gave enough information, because I don't know what to look for... I'm developing for 4.1.2

Complete Logcat

   06-20 13:02:38.823: W/ActivityThread(4102): Application eu.sexample.www can be debugged on port 8100...
06-20 13:02:38.983: D/dalvikvm(4102): GC_FOR_ALLOC freed 114K, 7% free 12283K/13191K, paused 13ms, total 13ms
06-20 13:02:38.988: I/dalvikvm-heap(4102): Grow heap (frag case) to 18.398MB for 5954576-byte allocation
06-20 13:02:39.008: D/dalvikvm(4102): GC_CONCURRENT freed 1K, 5% free 18096K/19015K, paused 12ms+1ms, total 22ms
06-20 13:02:39.053: D/dalvikvm(4102): GC_FOR_ALLOC freed 0K, 5% free 18097K/19015K, paused 10ms, total 10ms
06-20 13:02:39.088: I/dalvikvm-heap(4102): Grow heap (frag case) to 41.112MB for 23818256-byte allocation
06-20 13:02:39.103: D/dalvikvm(4102): GC_CONCURRENT freed 0K, 3% free 41357K/42311K, paused 3ms+1ms, total 16ms
06-20 13:02:39.168: D/dalvikvm(4102): GC_FOR_ALLOC freed 5815K, 16% free 35916K/42695K, paused 10ms, total 10ms
06-20 13:02:39.193: E/Location(4102): 51.1878642, 4.3802626
06-20 13:02:39.283: D/libEGL(4102): loaded /system/lib/egl/libEGL_mali.so
06-20 13:02:39.283: D/libEGL(4102): loaded /system/lib/egl/libGLESv1_CM_mali.so
06-20 13:02:39.288: D/libEGL(4102): loaded /system/lib/egl/libGLESv2_mali.so
06-20 13:02:39.288: D/(4102): Device driver API match
06-20 13:02:39.288: D/(4102): Device driver API version: 10
06-20 13:02:39.288: D/(4102): User space API version: 10 
06-20 13:02:39.288: D/(4102): mali: REVISION=Linux-r2p4-02rel0 BUILD_DATE=Tue Oct 16 15:37:13 KST 2012 
06-20 13:02:39.323: D/OpenGLRenderer(4102): Enabling debug mode 0
06-20 13:02:42.413: D/dalvikvm(4102): GC_FOR_ALLOC freed 448K, 14% free 37130K/42695K, paused 13ms, total 13ms
06-20 13:02:42.423: I/dalvikvm-heap(4102): Grow heap (frag case) to 42.664MB for 5954576-byte allocation
06-20 13:02:42.433: D/dalvikvm(4102): GC_CONCURRENT freed 4K, 12% free 42941K/48519K, paused 2ms+2ms, total 13ms
06-20 13:02:42.478: D/dalvikvm(4102): GC_FOR_ALLOC freed 0K, 12% free 42941K/48519K, paused 10ms, total 10ms
06-20 13:02:42.478: I/dalvikvm-heap(4102): Forcing collection of SoftReferences for 23818256-byte allocation
06-20 13:02:42.498: D/dalvikvm(4102): GC_BEFORE_OOM freed 9K, 12% free 42931K/48519K, paused 19ms, total 19ms
06-20 13:02:42.498: E/dalvikvm-heap(4102): Out of memory on a 23818256-byte allocation.
06-20 13:02:42.498: I/dalvikvm(4102): "main" prio=5 tid=1 RUNNABLE
06-20 13:02:42.498: I/dalvikvm(4102):   | group="main" sCount=0 dsCount=0 obj=0x41585508 self=0x415758c8
06-20 13:02:42.498: I/dalvikvm(4102):   | sysTid=4102 nice=0 sched=0/0 cgrp=apps handle=1074532144
06-20 13:02:42.498: I/dalvikvm(4102):   | schedstat=( 2709445063 154759556 1906 ) utm=227 stm=43 core=2
06-20 13:02:42.498: I/dalvikvm(4102):   at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
06-20 13:02:42.498: I/dalvikvm(4102):   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:623)
06-20 13:02:42.498: I/dalvikvm(4102):   at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:476)
06-20 13:02:42.503: I/dalvikvm(4102):   at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:781)
06-20 13:02:42.503: I/dalvikvm(4102):   at android.content.res.Resources.loadDrawable(Resources.java:1963)
06-20 13:02:42.503: I/dalvikvm(4102):   at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
06-20 13:02:42.503: I/dalvikvm(4102):   at android.view.View.<init>(View.java:3436)
06-20 13:02:42.503: I/dalvikvm(4102):   at android.view.View.<init>(View.java:3371)
06-20 13:02:42.503: I/dalvikvm(4102):   at android.view.ViewGroup.<init>(ViewGroup.java:426)
06-20 13:02:42.503: I/dalvikvm(4102):   at android.widget.RelativeLayout.<init>(RelativeLayout.java:184)
06-20 13:02:42.503: I/dalvikvm(4102):   at java.lang.reflect.Constructor.constructNative(Native Method)
06-20 13:02:42.503: I/dalvikvm(4102):   at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
06-20 13:02:42.508: I/dalvikvm(4102):   at android.view.LayoutInflater.createView(LayoutInflater.java:587)
06-20 13:02:42.508: I/dalvikvm(4102):   at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
06-20 13:02:42.508: I/dalvikvm(4102):   at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
06-20 13:02:42.508: I/dalvikvm(4102):   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
06-20 13:02:42.508: I/dalvikvm(4102):   at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
06-20 13:02:42.508: I/dalvikvm(4102):   at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
06-20 13:02:42.508: I/dalvikvm(4102):   at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
06-20 13:02:42.508: I/dalvikvm(4102):   at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:308)
06-20 13:02:42.508: I/dalvikvm(4102):   at android.app.Activity.setContentView(Activity.java:1924)
06-20 13:02:42.508: I/dalvikvm(4102):   at eu.sexample.www.MainActivity.onCreate(MainActivity.java:28)
06-20 13:02:42.508: I/dalvikvm(4102):   at android.app.Activity.performCreate(Activity.java:5206)
06-20 13:02:42.508: I/dalvikvm(4102):   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
06-20 13:02:42.508: I/dalvikvm(4102):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
06-20 13:02:42.508: I/dalvikvm(4102):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
06-20 13:02:42.508: I/dalvikvm(4102):   at android.app.ActivityThread.access$600(ActivityThread.java:140)
06-20 13:02:42.508: I/dalvikvm(4102):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
06-20 13:02:42.508: I/dalvikvm(4102):   at android.os.Handler.dispatchMessage(Handler.java:99)
06-20 13:02:42.508: I/dalvikvm(4102):   at android.os.Looper.loop(Looper.java:137)
06-20 13:02:42.508: I/dalvikvm(4102):   at android.app.ActivityThread.main(ActivityThread.java:4898)
06-20 13:02:42.508: I/dalvikvm(4102):   at java.lang.reflect.Method.invokeNative(Native Method)
06-20 13:02:42.508: I/dalvikvm(4102):   at java.lang.reflect.Method.invoke(Method.java:511)
06-20 13:02:42.513: I/dalvikvm(4102):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
06-20 13:02:42.513: I/dalvikvm(4102):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
06-20 13:02:42.513: I/dalvikvm(4102):   at dalvik.system.NativeStart.main(Native Method)
06-20 13:02:42.513: A/libc(4102): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 4102 (example.www)

Answer

CommonsWare picture CommonsWare · Jun 20, 2013

The real error is Out of memory on a 23818256-byte allocation. You are attempting to allocate a ~22MB block of memory, and you do not have that much free memory available, let alone a contiguous block that large.

In this case, this is coming from a drawable resource. ~22MB would be a truly massive image, more like 2400x2400 than 1200x1200.

Your process heap size is 48MB, which is substantial, but ~22MB is almost half your heap budget.

I would recommend that you find out which drawable resource this is (looks like it might be a background of a RelativeLayout), then reduce its size and the sizes of similar images. Here, by "size" I mean total pixel count, not the on-disk size, as what matters is the decompressed size in RAM, not how big the image is on disk.

Also, this might be an issue of resource directories. For example, if you put your 1200x1200 image in res/drawable/, that effectively is synonymous with res/drawable-mdpi/. If this device happens to be an -xhdpi device, then that would explain the memory usage, as Android will try to upsample this image and double each of the dimensions.