VM won't let us allocation... bytes while downloading images

I am building a news paper app for that I need to show news paper images(epaper) in gallary view... I need to download about 100 images. for that I use asyncTask and for every download image I create new AsyncTask object and,when I am trying to download image and set into gallary I have the error in middle "VM won't let us allocation... bytes" and crash the app.

new AsyncTask<String, Void, Bitmap> () {

                protected Bitmap doInBackground(String... params) {
                    HttpGet httpRequest;
                    try {
                        httpRequest = new HttpGet(new URL(params[0]).toURI());
                        HttpClient httpClient = new DefaultHttpClient();
                        HttpResponse response = (HttpResponse) httpClient.execute(httpRequest);
                        HttpEntity entity = response.getEntity();
                        BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity); 
                        InputStream is = bufHttpEntity.getContent();
                        return BitmapFactory.decodeStream(is);

                    } catch (MalformedURLException e) {
                    } catch (URISyntaxException e) {
                    } catch (ClientProtocolException e) {
                    } catch (IOException e) {
                    }/* catch (Error e) {
                    return null;

                protected void onPostExecute(Bitmap result) {
                    if(result != null) {


show the error in logcat:

Please help me

Thanks in advance.


You should definetly not keep 100 Bitmaps on memory at the same time. You need to download only the Bitmaps needed and then call recycle() before downloading new Bitmaps.

Have a look at this exaple for the preferred way of doing what you want: ImageDownloader

Another option for image loading that I use is Prime, I use it in all of my projects and its pretty simple and efficient.

Need Your Help