Even though the memory size of mobile device is getting more and more, it is always a good habit for programmer to understand the real memory distribution and make use of moderated amount of memory. On Android a typical application have two kinds of memory: native and managed.
For native part, we have several tools to access it.
- /proc/$pid/smaps
- procmem
- top
For mananged part, we can make use of MAT tool to access it.
The detail usage of above tools need much amount of words, I will add it later.
I want to mention here one scenario about memory leak in java. In Java the instance of inner class have the reference to the instance of parent class in which it's defined. If the instance of inner class passed to other object, then that object will hold the direct or indirect reference to the inner class instance and parent class instance. If not take care of this, memory leak will happen.