How to avoid OutOfMemory Exception in android?

By | July 23, 2011

Hello all..

The OutofMemory exception is a common exception in android when you select an image from a gallery or load Big Images in android.
There are different methods to solve this problem.
Today I will show you one of the method to solve this problem.

The method I am going to explain here is to create a virtual device with more

1. RAM
2. Heap Size
3. SDCard support.

The main reason for this problem is that if the virtual device you created has less configuration, then it will not allocate more heap size for bigger images.
In this tutorial I will show you how to create a Virtual device with higher configuration.

Follow these steps

1. Open Eclipse -> Window -> Android SDK and AVD Manager.
2. Click new -> Give a Virtual device name and other details like Target and SDCARD size.
3. In the Hardware tab below click on new
4. See the options in the combobox.
5. Give appropriate values after selecting values from the Box after clicking ok. Try to give bigger values than default

See the figure below.

In the coming posts I will explain another two methods to avoid this exception. Keep in touch.

Click the +1 button on the top to share it with your friends and please leave your valuable comments also.

One thought on “How to avoid OutOfMemory Exception in android?

  1. pravin

    Hi ,

    The same problem i am facing in my application using with image in android. so please let me know your answer on it.



Leave a Reply

Your email address will not be published. Required fields are marked *