Posts Tagged 'Memory Leaks'

Android: Finding Memory Leaks

Recently while I was working on the next version of Archer Master, I’ve had to roll up my sleeves and find a memory leak. By and large, a memory leak in one’s application is frequently a synonym for having painful time, no matter which language you’re coding in. I have experience in finding leaks in the non-managed languages such as C/C++ but this was my very first time with a managed language (Java). In my case, the leak was caused by a lost strong-reference to a LinearLayout used to hold advertising, so each time a level was played, the entire activity remained in memory and wasn’t collected. As a result, after playing several levels (the number depended upon the particular device), a OOM exception raised and the game crashed.

It’d have been virtually impossible to find the leak without a tool like MAT. Moreover, a good understanding of the different types of references (strong, weak, soft…) and the concept of Dominator Tree  also help.

When I’ve got a little more time I’ll write about the whole process I went thru (if anyone is really interested please let me know)… but meanwhile, this is an invaluable resource if you find yourself in a similar situation and don’t know how to start:

Good luck with your leaks! 😉

_______________________________________________________________

Advertisements

Who’s in charge here?

Follow me on Quoders Blog…



Quoders Twitter

License