[android-developers] Re: Activity Back Stack and OutOfMemoryError
Android has this particular annoying and weird behavior: Once the heap inflates to a certain size, no matter how much of it is actually used, you can no longer allocate files that are larger than the remaining memory. my guess, you're there. you should make sure your previous activities use as little memory as possible and make it a habit of unloading memory which might not be necessary once activities are changed. This is especially true in apps that store large bitmaps and even more noticeable if you also have lots of small objects (memory fragmentation + large bitmaps = OOM exceptions) On Thursday, May 8, 2014 5:47:06 PM UTC+3, Daniel Rindt wrote: Hello, in the application we open a chooser for selecting photos. I got frequently crashes mostly from sony by doing this which says: OutOfMemoryError which raises by showing the bitmaps. The stacktrace which the system creates doesn't mention a class of our code which confuses me a bit. My assumption is that our app can open lots of activities and by opening the image choose there is not much space left and the crash happen. So far i read i shouldn't care about do finish(); and activity they can remain in the activity backstack. It would be great to get a bit more clued. Here is the stacktrace i got: Package: com.viselabs.aquariummanager Version Code: 34 Version Name: 0.16.34.g3cc9d12 Android: 4.3 Manufacturer: samsung Model: SPH-L710 Date: Thu May 08 09:13:04 EDT 2014 java.lang.RuntimeException: Unable to start activity ComponentInfo{android/com.android.internal.app.ChooserActivity}: android.view.InflateException: Binary XML file line #26: Error inflating class unknown at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2305) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2359) at android.app.ActivityThread.access$700(ActivityThread.java:165) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1326) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5455) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003) at dalvik.system.NativeStart.main(Native Method) Caused by: android.view.InflateException: Binary XML file line #26: Error inflating class unknown at android.view.LayoutInflater.createView(LayoutInflater.java:626) at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) at android.view.LayoutInflater.onCreateView(LayoutInflater.java:675) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:700) at android.view.LayoutInflater.rInflate(LayoutInflater.java:761) at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) at android.view.LayoutInflater.inflate(LayoutInflater.java:498) at android.view.LayoutInflater.inflate(LayoutInflater.java:398) at android.view.LayoutInflater.inflate(LayoutInflater.java:354) at com.android.internal.app.ResolverActivity.onCreate(ResolverActivity.java:210) at com.android.internal.app.ChooserActivity.onCreate(ChooserActivity.java:69) at android.app.Activity.performCreate(Activity.java:5372) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2267) ... 11 more Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.constructNative(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:417) at android.view.LayoutInflater.createView(LayoutInflater.java:600) ... 24 more Caused by: java.lang.OutOfMemoryError at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:596) at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444) at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:832) at android.content.res.Resources.loadDrawable(Resources.java:2988) at android.content.res.Resources.getDrawable(Resources.java:1558) at android.widget.EdgeEffect.init(EdgeEffect.java:148) at android.widget.AbsListView.setOverScrollMode(AbsListView.java:1220) at android.view.View.init(View.java:3458) at android.view.View.init(View.java:3528) at android.view.ViewGroup.init(ViewGroup.java:475) at android.widget.AdapterView.init(AdapterView.java:236) at
Re: [android-developers] Re: Activity Back Stack and OutOfMemoryError
2014-05-11 14:00 GMT+02:00 Piren gpi...@gmail.com: Android has this particular annoying and weird behavior: Once the heap inflates to a certain size, no matter how much of it is actually used, you can no longer allocate files that are larger than the remaining memory. my guess, you're there. you should make sure your previous activities use as little memory as possible and make it a habit of unloading memory which might not be necessary once activities are changed. This is especially true in apps that store large bitmaps and even more noticeable if you also have lots of small objects (memory fragmentation + large bitmaps = OOM exceptions) I have inspected the code as Kostya mentioned, and i haven't seen anything what looks like a leak, all the memory was released after causing a gc manually. And i carefully checked every activity and its fragments. I only come to the conclusion that what you said must be the case i have no other answer for that. So will change the behavior of opening lots of activities. But in future it should be wise considered in the concept. Thank you for all readers and who respond. Daniel -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups Android Developers group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.