We should monitor the memory when simulate our app.



I have faced a problem during coding my android app. It was crashed when simulating on my actual device. Beside, reading an error or an exception on ‘logcat’. We may need to monitor it as well.


(Just click at Android -> Monitor to monitor your usage of Memory, CPU or network)


I have found that my app’s problem occurred from much usage of memory that came from I have not sampled my image size properly. So, this feature of android studio could be very useful.  We can working something more with this Memory monitoring like we can test to cause a ‘Gabage collection’ event and see – does our app still working properly when garbage collection occurring?  By just pressing this button 

(Press ‘initiate GC’ button to manual cause some garbage collection)

It sounds as easy as calling your gentle garbage man to pick you garbage up even you have none of them.


We may want to see more detail about memory usage by pressing the ‘Dump Java Heap’ button 

(Press Dump Java Heap to see details of memory usage)

Here we go! The memory usage data will be shown as the below image


We may be able to investigate further from this page, which class is using the most memory or which class may causing some problem on our app.
Here is a useful official link from android.com that teach us how to read these data


You may want to get these sequence of information in a form of period of time. So, pressing the ‘Start allocation Tracking’, waiting until you want to abort the recording then press ‘Stop allocation Tracking’ button.

 The allocation tracking dumped file (of you memory usage) will be saved on your‘/[App directory]/capture’ folder. Now, you can open the file whenever you want to investigate your memory usage of your app. 

Well, as usual, Thank you for reading until the end. I'm not only fond of writing but also love to read. If you have something similar or a better solution, Please share it to me by writing down on the comment or send us an Email directly. Many Thanks!

Comments

Popular posts from this blog

Logic thinking to solve a problem that occurred on unfamiliar system

They thought we can't code - I built my own Networking tool app up.

When Gradle don't know your new added Native code