- Change string concatenation to StringBuffer.append()
- Try using the context-application instead of a context-activity
- Shorten session timeout call HttpSession.invalidate(). when app exit()
- Avoid non-static inner classes in an activity if you don't control their life cycle, use a static inner class and make a weak reference to the activity inside. The solution to this issue is to use a static inner class with a WeakReference to the outer class, as done in ViewRoot and its W inner class for instance (Not sure how to do it. I know "using strong references for parent-to-child references, and weak references for child-to-parent references, thus avoiding cycles". It'll need to trace the code like View<->Context kind of stuff)
- Watch later http://stackoverflow.com/questions/1147172/what-android-tools-and-methods-work-best-to-find-memory-resource-leaks
- Watch later http://www.curious-creature.org/
- LBNL : http://developer.android.com/tools/debugging/ddms.html
References
http://android-developers.blogspot.co.uk/2009/01/avoiding-memory-leaks.html
http://www.mindfiresolutions.com/How-to-avoid-Memory-leak-issue-in-Java-1001.php
http://en.wikipedia.org/wiki/Weak_reference
http://www.ibm.com/developerworks/java/library/j-leaks/
沒有留言:
張貼留言