I think it is asked and asked before, but still, there are things I can't quite understand.
I have tried two different approaches:
- Keep all the images in memory, when certain limit is started to exceed, start removing them
- Let Android fix this with SoftReferences
In 2. it's just cleaning them up sometimes the second I allocate them! And I don't allocate too much - 30-40 images 50x50 pixels.
So I am sticking to one. The question is what is the limit?
- Can I get some reliable info from the device of how much exactly bitmap memory do I have left? I have done some research, watch DDMS values, it's just taking up more and more space (if I don't clean up) until it explodes. One moment there are only 200K left, next the system provides 2M more...
- I am currently using some heuristic decision, based on device model, or screen size. I think this is dead-end in the long run. Got memory exceptions on some phones, completely free on other.
- Is there a third solution, the right one?