Reputation: 2637
In short, I'm trying to avoid memory leaks. I have read http://kohlerm.blogspot.co.uk/2009/02/memory-leaks-are-easy-to-find.html and I have identified some, by looking at what kept the GC from releasing the memory.
That said, I'm still not sure what should be ALWAYS manually released by doing things like: - unregistering listeners - nulling references - removing views from layouts
... versus what is automatically released when the system destroys the application.
Upvotes: 1
Views: 490
Reputation: 14038
Some things I could point out You need to do when Activity
is getting paused :
Making sure you are not using static rferences to the context or the activity or views. Make them null if you are.
Stop the media being played ( if any) and release mediaplayer's resources. They are very limited.
A surfaceholder gets destroyed if an activity is paused, will have to release resources.
Save all the necessary vaiables/state as it is last lifecycle method guaranteed to be called.
Stop animations, timers, asyctasks as per your need.
Upvotes: 4