I have a Grid View in my android app.I am loading images to the Grid view from server.I am using lazy loading. I have to recycle all bitmaps created here.How to do Bitmap.recycle() in Adapter or Grid view. I am getting out of memory, please help me.
Share
You will need to show some code (your adapter at a minimum). If you’re getting out of memory errors, you probably are not implementing view recycling correctly, or otherwise have a memory leak. Its also possible that you’re simply loading too many large bitmaps at once, but if you can load the view at all, its much more likely you have a memory leak.
No one is going to be able to track down a memory leak without looking at some code. Bitmap.recycle() is not a solution, the garbage collector will work well enough without it if the rest of your code is ok.
See: http://www.youtube.com/watch?v=_CruQY55HOk for a great talk on managing memory in android and finding memory leaks.
Also try: http://android-developers.blogspot.com/2010/07/multithreading-for-performance.html for an example of how to download or otherwise correctly asynchronously load images into a list like view.
Edit: also check out an image loading library I wrote, so you don’t need to worry about any of this: https://github.com/bumptech/glide