Android Performance Test--memory Monitor tool
What can Memory monitor do?
- Real-time view of the app's memory allocation
- Quickly determine if the app is stalling due to GC operations
- Quickly determine if the app's crash is out of memory
Memory Monitor Use Preparation
- Developer options available
- USB Debug Enabled
Note: The Android studio is Enable ADB Integration checked (tools/android).
Memory Monitor Panel
The first step is adb devices to make sure the device is available, then start Android Studio , select an Android project or create a new project to go to the main panel, if you have the source of the app you are testing, then it is best to go into your own app project, so as to facilitate debugging and positioning problems. After entering the project, you can see a tab in the lower left corner of the main panel of Android studio Android :
Click the tab to open the Android panel as shown in:
A: Equipment Selection
B: selectable Apps for monitoring
C: Real-time data for memory
Focus on the C area, the horizontal axis record from the acquisition start point to the past time, the ordinate is allocated to the app to use the total amount of memory [Allocated+free], the blue area is allocated [allocated] used, the gray area indicates idle [free] unused. The exact value can be seen on the right side of the axis.
Gc
GC is the meaning of garbage collection, we can see from memory monitor when the GC event occurred, when a memory drops in a short time, we can assume that a GC operation occurred. You can also manually trigger GC, in which the small car is the button that triggers the GC, and once it is pressed, it will reclaim those objects that are not referenced (this place cannot be said to be useless, because the useless object is likely to be the object of the memory leak, which will be studied later):
The problems that Memory Monitor can find
The Memory Monitor tool is a monitoring tool, a discovery type or a monitoring tool, such as a doctor's four skills [palpation],[] is the first step. The memory monitor here is a kind of [look] tool, I mainly use it to look at the following a number of problems:
1. Scenarios where memory jitter is found
2. Discover scenarios where large memory objects are allocated
3. Discover the growing memory scene
4. Determine if the lag problem is due to a GC operation
Case analysis
The first paragraph of the above indicator shows that the memory suddenly increased by 7M, we can see very clearly, so this point we have to locate the problem where, is bitmap or what cause, the second paragraph mark is memory jitter, it is obvious in a very short time the memory allocation and release of multiple times. And in the event of memory jitter, you can also feel the app's lag, can be seen as a result of performing a GC operation.
The constant increase in memory is easy to see by using Memory Monitor, and the blue curve is all the way up, and it's a sight to know.
Issues with memory leaks
Memory monitor can also be summed up as a tool for detecting leaks, but I didn't, because in the real world, when the leak points are small each time, it's hard to see that there is no heap viewer to work with. If the leaking object takes up a large memory, it can also be seen through the memories Monitor.
Android Performance Test--memory Monitor tool