seems this is a reported bug? http://code.google.com/p/android/issues/detail?id=294
-- Best Regards, Atif Gulzar I ◘◘◘◘ Unicode, ɹɐzlnƃ ɟıʇɐ On Tue, Nov 10, 2009 at 5:51 PM, Atif Gulzar <atif.gul...@gmail.com> wrote: > Hi, > > Would you please help me how to handle the memory leak on > Drawable.createFromStream()? > > I am receiving a base64 image from a webservice. And I decode it using > Apache lib. After that I convert it to drawable through > Drawable.createFromStream(). But when the image size is bit larger (~>350kb) > it starts throwing OutOfMemoryError exception. Ok, I can handle this by > catching this exception. But eventually after catching 2 or 3 such > exceptions the heap is full and it start throwing exceptions for other > methods and for small images as well. > > The relevant code snip is given below. > > > byte[] arr = null; > InputStream imageStream = null; > try > { > arr = Base64.decodeBase64(result.getScreenShot().getBytes()); > > imageStream = new BufferedInputStream(new > ByteArrayInputStream(arr)); > TJCAppDetail.this.screenShotDrawable = > Drawable.createFromStream(imageStream, "src"); > screenShot.setImageDrawable(screenShotDrawable); > } > catch (OutOfMemoryError outOfMemoryError) > { > arr = null; > imageStream = null; > if (screenShotDrawable != null) > { > screenShotDrawable.setCallback(null); > if (((BitmapDrawable) screenShotDrawable).getBitmap() != null) > ((BitmapDrawable) > screenShotDrawable).getBitmap().recycle(); > } > > Log.e("TJC_EXCEPTION", outOfMemoryError.getMessage()); > } > > > > -- > Best Regards, > Atif Gulzar > > I ◘◘◘◘ Unicode, ɹɐzlnƃ ɟıʇɐ > > -- 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