Hello,

The framework (and support library) contains a class that you might find 
useful LruCache ;)

I will also highlight this training section
http://developer.android.com/training/displaying-bitmaps/index.html

BTW, if your know your application will use a lot of memory, you should 
query for heap size at runtime using 'ActivityManager.getMemoryClass()'

Regards

On Friday, July 6, 2012 6:16:17 PM UTC+2, Android Developer wrote:
>
> Hi,
>
> I am working in a avatar like application that has lots of images more 
> than 1000 where user can change any image at runtime. But its frequently 
> running out of heap space and then crashed.
>
> I checked this. 
> http://developer.android.com/training/displaying-bitmaps/index.html 
>
> But it didnt solve my problem. Even i have worker thread to update the 
> image to UI. 
>
>
> *Stack Trace : 
>
>
> 07-06 21:54:45.707: E/AndroidRuntime(14405): java.lang.OutOfMemoryError
> 07-06 21:54:45.707: E/AndroidRuntime(14405):     at 
> android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
> 07-06 21:54:45.707: E/AndroidRuntime(14405):     at 
> android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:483)
> 07-06 21:54:45.707: E/AndroidRuntime(14405):     at 
> android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:351)
> 07-06 21:54:45.707: E/AndroidRuntime(14405):     at 
> android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:773)
> 07-06 21:54:45.707: E/AndroidRuntime(14405):     at 
> android.content.res.Resources.loadDrawable(Resources.java:1935)
> 07-06 21:54:45.707: E/AndroidRuntime(14405):     at 
> android.content.res.Resources.getDrawable(Resources.java:664)
> 07-06 21:54:45.707: E/AndroidRuntime(14405):     at 
> android.widget.ImageView.resolveUri(ImageView.java:542)
> 07-06 21:54:45.707: E/AndroidRuntime(14405):     at 
> android.widget.ImageView.setImageResource(ImageView.java:315)
> 07-06 21:54:45.707: E/AndroidRuntime(14405):     at 
> android.os.AsyncTask.finish(AsyncTask.java:602)
> 07-06 21:54:45.707: E/AndroidRuntime(14405):     at 
> android.os.AsyncTask.access$600(AsyncTask.java:156)
> 07-06 21:54:45.707: E/AndroidRuntime(14405):     at 
> android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:615)
> 07-06 21:54:45.707: E/AndroidRuntime(14405):     at 
> android.os.Handler.dispatchMessage(Handler.java:99)
> 07-06 21:54:45.707: E/AndroidRuntime(14405):     at 
> android.os.Looper.loop(Looper.java:137)
> 07-06 21:54:45.707: E/AndroidRuntime(14405):     at 
> android.app.ActivityThread.main(ActivityThread.java:4424)
> 07-06 21:54:45.707: E/AndroidRuntime(14405):     at 
> java.lang.reflect.Method.invokeNative(Native Method)
> 07-06 21:54:45.707: E/AndroidRuntime(14405):     at 
> java.lang.reflect.Method.invoke(Method.java:511)
> 07-06 21:54:45.707: E/AndroidRuntime(14405):     at 
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
> 07-06 21:54:45.707: E/AndroidRuntime(14405):     at 
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
> 07-06 21:54:45.707: E/AndroidRuntime(14405):     at 
> dalvik.system.NativeStart.main(Native Method)
>
>
> *Thanks in Advance
> *
> *
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to