Drawable.createFromStream() and OutOfMemoryError exception

by Atif Gulzar » Tue, 10 Nov 2009 22:11:45 GMT


Sponsored Links
 seems this is a reported bug?
 http://code.google.com/p/android/issues/detail?id=294 


--
Best Regards,
Atif Gulzar

I  Unicode, zln 







--



Drawable.createFromStream() and OutOfMemoryError exception

by Atif Gulzar » Wed, 11 Nov 2009 12:05:59 GMT


 ump

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.





On Tue, Nov 10, 2009 at 7:11 PM, Atif Gulzar <atif.gul...@gmail.com> wrote:


--


Sponsored Links