Re: [android-developers] [BUG] Easily Reproducable Bug in Regards to Bitmaps, Memory, and Recycling [sample project included]
This error message is usually not related to the GC. This message is logged when recycle() is called twice on the same bitmap. Considering you are doing your own bitmap management and calling recycle yourself in BaseForm I would suspect a bug in your code. On Fri, Jan 7, 2011 at 9:44 AM, Mark Murphy wrote: > On Fri, Jan 7, 2011 at 12:36 PM, Joe McCann > wrote: > > Also, it appears this is a bug that is "declined" by the Android > > team. "Use less memory in your app" was the original solution > > suggested by Romain Guy. > > > > http://code.google.com/p/android/issues/detail?id=8488 > > The issue you list here would appear to have nothing to do with your > problem, considering that your error ("trying to use a recycled > bitmap") appears nowhere in that issue. > > -- > Mark Murphy (a Commons Guy) > http://commonsware.com | http://github.com/commonsguy > http://commonsware.com/blog | http://twitter.com/commonsguy > > Warescription: Three Android Books, Plus Updates, One Low Price! > > -- > 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 > -- Romain Guy Android framework engineer romain...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them -- 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
Re: [android-developers] [BUG] Easily Reproducable Bug in Regards to Bitmaps, Memory, and Recycling [sample project included]
On Fri, Jan 7, 2011 at 12:36 PM, Joe McCann wrote: > In a nutshell, I have/am trying to create reusable UI components in > XML. I created a dead simple project that only fires an activity to > show the UI. Your "dead simple project" will not run on any version of Android, due to a typo in your manifest. Also, on the Android 2.3 emulator, your "dead simple project" crashes immediately with a "bitmap size exceeds VM budget". Your problem can be solved by removing your recycle() call and putting your background PNG into the appropriate resource sets (drawable-ldpi, drawable-mdpi, drawable-hdpi). This has a side benefit of allowing your application to run on Android 2.3. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Warescription: Three Android Books, Plus Updates, One Low Price! -- 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
Re: [android-developers] [BUG] Easily Reproducable Bug in Regards to Bitmaps, Memory, and Recycling [sample project included]
On Fri, Jan 7, 2011 at 12:36 PM, Joe McCann wrote: > Also, it appears this is a bug that is "declined" by the Android > team. "Use less memory in your app" was the original solution > suggested by Romain Guy. > > http://code.google.com/p/android/issues/detail?id=8488 The issue you list here would appear to have nothing to do with your problem, considering that your error ("trying to use a recycled bitmap") appears nowhere in that issue. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Warescription: Three Android Books, Plus Updates, One Low Price! -- 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
[android-developers] [BUG] Easily Reproducable Bug in Regards to Bitmaps, Memory, and Recycling [sample project included]
In a nutshell, I have/am trying to create reusable UI components in XML. I created a dead simple project that only fires an activity to show the UI. It can be downloaded here: http://dl.dropbox.com/u/409429/Bitmap%20Bg%20Test.zip I have a "base_form.xml" component that is referenced (setContentView()) in "BaseForm.java", a base Activity. The base_form.xml is a FrameLayout where the background is set to a drawable (a 16 kb png). I now have "LoginForm.java" that extends BaseForm and a subsequent "login_form.xml" component. This login_form component is inflated in LoginForm.java and "appended" to the view and remember, the view was set in BaseForm.java via setContentView(R.layout.base_form). It should be noted that in the BaseForm.java there is a method called "cleanupDrawables()" which recycles the bitmap being used in the FrameLayout and sets various things to null. It even explicitly calls System.gc() (I've tried it without and still the same issue). Upon firing the app, everything works fine. UI loads up and displays properly. Now, hit the back button. Now, open the app again. Everything is fine. Hit the back button again. Now open the app again. Breaks with this exception: FATAL EXCEPTION: main E/AndroidRuntime( 405): java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.bit...@44f4c150 So after discussing this issue with some other engineers it appears it is a bug in the garbage collector that is occurring after the 2nd sweep. Apparently a very similar bug existed in early .Net. A solution may be to instead of defining the background in XML to load a bitmap using BitmapFactory and explicitly set the background of the FrameLayout in Java. This is undesirable as it doesn't really allow me to create reusable UI components in XML. Any help is greatly appreciated. Also, it appears this is a bug that is "declined" by the Android team. "Use less memory in your app" was the original solution suggested by Romain Guy. http://code.google.com/p/android/issues/detail?id=8488 -- 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