2

I am Working with one android tablet application in which lots of work with Images.

i have to load hundred of large bitmap images in scroll view. one image is around 1Mb to 3 Mb.
i have already scale images using bitmap factory and sample size, and also load all the images in Async task.
i am loading all the images from SD card.

Still facing OUT OF MEMORY issue after scrolling some images. any help would be appreciated. thanks in advance.

9
  • See Displaying Bitmaps efficiently in order to understand how to use Bitmaps Commented Feb 14, 2014 at 5:27
  • i have already used it, it's working fine. still facing issue due high bitmap images. is there any other solution ? Commented Feb 14, 2014 at 5:28
  • why dont you use thumbnail of image.? Commented Feb 14, 2014 at 5:31
  • 1
    why are you using ScrollView? does ListView is not helpful to you? with ListView, you can handle memory efficiently as it recycles and reuses it's Views as scrolling up and down where as ScrollView loads all it's Views at a time... Commented Feb 14, 2014 at 5:38
  • @wqrahd: I mast have to display image on full size on screen. Commented Feb 14, 2014 at 5:46

5 Answers 5

6

hi hope your solution.

you can user Univarsal Image Loader. This is better api for image download and store in catch. and get from catch. it's a great api for image operation.

Sign up to request clarification or add additional context in comments.

2 Comments

Univarsal Image Loader help me little bit but still getting Out of Memory Error after some time in Imageloader class.
I am using univarsal image loader api. and it show 4.5 mb size image but i can't got out of memory error problem.
1

this case is often come while we getting bitmap so just use lazy loading. just take a look on this example http://sunil-android.blogspot.in/2013/09/lazy-loading-image-download-from.html

2 Comments

i am loading all the images from SD card.
doesn't mean dude lazy loading is also apply for sdcard pic take this example android-er.blogspot.in/2013/10/…
0

To prevent your application from soaking up CPU time without getting anything done, the JVM throws this Error so that you have a chance of diagnosing the problem.

Its because of large bitmap memory in stored in native area so it better i suggest you use libraries like Universal Image Loader or

Bitmap Fun from android

4 Comments

i am loading all the images from SD card.
you can use universal image loading library for retieving images fron sd card by passing file path
Univarsal Image Loader help me little bit but still getting Out of Memory Error after some time in Imageloader class.
In this case,its better to use listview rather than scrollview
0

You have to find out when the OOM error occurs. Is it when you have too much bitmap cache in memory without releasing or you just meet it when you're decoding certain bitmap?


For the first situation, I think you should manage your bitmap cache yourself or using some effective 3rd-party library which mentions above.


For the second situation, I've met it on some low-performance mobile(usually with 512MB or less memory), when you decode a bitmap to requested size, it may needs a rather large memory to store the bitmap, for 240dpi devices, it's about 800 * 480 * 4 = 1.5MB, however you may fail to allocate that much memory on some machines cause they may have strict memory manage strategy to prevent that much memory allocation. You should just catch the OOM error and continue rather than get a crush.

Comments

0

Loading a bitmap in 1280x800 display will take 1280x800x4 byte (~4MB) memory. Java heap size is limited (~50MB) so you can not use lots of large bitmaps in your app. Using cache and reusing bitmap objects are necessary while working with bitmaps but another useful trick is to use larger hip size! to do so, add android:largeHeap="true" to Application tag in your manifest. It increases hip size to 4 or 5 times larger (~250MB) than normal. I hope this help other people reaching this thread while they search!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.