Click here to Skip to main content
15,900,686 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I created image gallery acitivity.I assign event to each image so when user click on image, application start new activity.All is OK but is one problem. When I scroll down image gallery and nest scroll up gallery and next clik on button often application throw Out of Memmory Exception. In other situations,application always works good.
I've searched the entire internet and and I found a lot of posts about Out of Memmory Exception.
So I use method as decodeSampledBitmapFromResource or calculateInSampleSize following this website:
but still application throw error.
How solve my problem??
Sergey Alexandrovich Kryukov 28-May-14 17:25pm    
Without knowing a lot of detail of your project, its hardly possible to advise anything certain. You have out of memory exception, so what? Eventually, it always can happen if you are trying to use a lot of memory. You can probably redesign your code the ways it keeps, for example, most of the images on the drive and load them into memory only when it is required. Or something like that. After all, no one needs to see all the images at once.
ridoy 3-Jun-14 16:20pm    

1 solution

Please see my comment to the question. We cannot see any detail of your project, but probably you can redesign it to work better with memory. Please consider this: no user can see more image pixels than the number of pixels on the whole screen. So, you can load images only to cover one screen. In practice, for performance reasons, you can preload more images, say, worth of 3-4 screen sizes or a bit more. For that amount of memory, I hope your RAM would be sufficient. And then unload and reload images on the fly.

If you need more detailed advice, you probably need to supply more information on your project.

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900