Android Performance Test--heap Viewer tool

Source: Internet
Author: User

Android Performance Test--heap Viewer tool

What can the Heap viewer do?
    • Real-time view of the app's allocated memory size and free memory size
    • Discover the memory Leaks
Heap Viewer conditions of Use
    • More than 5.0 of the system, including 5.0
    • Developer options available
Heap Viewer Startup

You can directly click on the small robot launcher directly in the Android Studio toolbar:

You can also have tools in the menu bar of Android Studio:

If you don't use Android studio, you can open the monitor program under tools under the SDK:

Heap Viewer Panel

By pressing the tag order, we can see the specific data of the memory, the value in the right panel will change every time the GC, including the app automatically triggered or you to manually trigger.

OK, now to explain the noun in the bottom plate

General overview

Column Name meaning
Heap Size The amount of memory allocated to the app by the stack
Allocated Amount of memory allocated for use
Free Free memory size
%used Allocated/heap Size, utilization
Objects Number of objects
Details

type meaning
Free The Idle Object
Data Object Data objects, class-type objects, most important objects of observation
Class object Reference objects of class type
1-byte Array (byte[],boolean[]) An array object of one byte
2-byte Array (short[],char[]) Two-byte array object
4-byte Array (long[],double[]) 4-byte Array object
Non-java Object Non-Java objects

Here is the meaning of the column names for each object:

Column Name meaning
Count Number
Total Size Total amount of memory consumed
Smallest Objects occupy memory size from small to large, the first object occupies memory size
Largest The size of the object that takes up memory from small to large rows, and the last object that occupies the memory size
Median The size of the objects in the middle of the memory size from small to large rows
Average Average

When we click on a row, we can see the following bar chart:

The horizontal axis is the memory size of the object, which is different with different objects, and the ordinate is the number of objects on a certain memory size

Use of the Heap Viewer

We say that the heap viewer is suitable for memory leaks, do you know what a memory leak is?

Memory leaks

English Name: Memory Leaks
Standard explanation: Useless simple, but still no GC root reference memory
Popular Explanation: Damn Undead Memory

Detection

So how to detect it? The values in the Heap Viewer are automatically updated each time the GC occurs, so are we waiting for his own GC? Little brother, just at the beginning I was so always wait ah, because the timing of the GC is the system grasp, so it is very difficult to grasp, since we are looking at memory leaks, then we need to detect the memory leak of the use case after the execution, manual GC, and then observe data object a column total size (also can observe the heap Size/allocated memory situation), to see if the memory is going back to a stable value, after multiple operations, as long as the memory is stable at a certain value, then there is no memory overflow, if found within each GC, growth, whether slow growth or rapid growth, all indicate the possibility of a memory leak.

Instance

Let's take a look at 3 graphs:
1. Just open the homepage, manual GC for a bit:

2. Home page to Details 10 times, finally back to the homepage, manual GC, until the value no longer changes:

3. Home to the Details page 10 times, and finally back to the home page, manual GC for a bit:

From data object one column to see that the type of values will be growing, there may be a memory leak, and we can also from the above three graphs in the Red section, allocated respectively increased 2.418M and 1.084M , and you continue to do so, memory is still the trend of growth

Add

The heap viewer is not only used to detect memory leaks, but we can also use this tool to detect memory jitter, because when memory jitter occurs, GC is frequent, and we only need to open the heap viewer to observe the changes in the data, and if memory jitter occurs, The data is observed to be updated frequently during the time period.

Android Performance Test--heap Viewer tool

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.