[android-developers] Re: Memory leaks when using bitmaps in android

2011-12-22 Thread String
When chasing a problem like this a couple of years ago, my testing seemed to indicate that setting a bitmap to null right after a call to recycle() was leaky. It was as though the recycle call needed some time to work, and setting null got in the way. I found it was better to just call recycle

Re: [android-developers] Re: Memory leaks when using bitmaps in android

2011-12-22 Thread Miguel Morales
Working with bitmaps is a little hard on Android. One thing to do is to resize or pack them so that they take up less memory. Another thing you may want to look into is to reuse the bitmap object/memory. You may have to do this in native though. As other have pointed out System.gc() just gives

[android-developers] Re: Memory leaks when using bitmaps in android

2011-12-21 Thread shyama
Sorry for the large code. Thanks for your help. What I would like to know is when to use weak references and if it is a good option while using Bitmaps? If so how does it help? /** This is the onPause function which releases the bitmap when the imagebutton is clicked and gallery is displayed.

[android-developers] Re: Memory leaks when using bitmaps in android

2011-12-20 Thread shyama
I realised that when when I made a call to System.gc() right after the bitmao..recycle() call the heap space is getting returned to the VM heap. But I have been reading about Garbage collection and it seems that calling System.gc() is not a good programming practice. Is there another way to make

Re: [android-developers] Re: Memory leaks when using bitmaps in android

2011-12-20 Thread James Black
You should work on getting a smaller example to demonstrate as this is too much code to read through. It may also help you solve the problem yourself. On Dec 20, 2011 3:21 PM, shyama shyama.asoka...@gmail.com wrote: I realised that when when I made a call to System.gc() right after the

[android-developers] Re: Memory leaks when using bitmaps in android

2011-12-20 Thread lbendlin
A call to System.gc() doesn't actually start the GC process. All it does is add the request to the queue. The operating system will then decide at its leisure when to actually do the GC. So even calling System.gc() repeatedly (as is sometimes recommended) is just another word for desperation.