Android Terminal Performance test--memory

Source: Internet
Author: User

Objective

Do Android QQ performance test, memory test encountered a lot of confusion, "all kinds of" memory terminology, exactly what meaning, how to get, summed up here.
There are two main aspects of memory testing, one, the discovery and positioning of oom, two, a comparison test with a historical version or a competitor. About Oom can be analyzed using mat, see Susanwu in the article on the KM "How to use Memory_analyzer to analyze memory leaks." Here is a summary of the most common methods and explanations for Android performance testing

One: Running Services "View service process memory

Starting with Android 2.0, a new activity ("Running Services" activity) was added to settings to show the memory usage of each service process currently running and the approximate memory usage of the entire phone. You can enter the activity through setting->applications->running services.
It is important to note that some applications may have several processes, but only one of those processes is shown here. For example, the running services activity sees only the memory information of the child process Com.tencent.mm:push, so this statistic is sometimes unreliable.

Two: Common shell commands to get:1. Procrank command, Procrank can obtain the following memory information at the same time:

VSS: Virtual Set size consumes memory (contains memory consumed by shared libraries). This is the size also includes memory that May is resident in RAM like Mallocs that has been allocated but not written to, so Using VSS to measure the actual memory used by a process is of little significance.

Rss:resident Set size actually uses physical memory (contains the memory occupied by the shared library). RSS can be misleading, because it reports the total all of the the the A-Libraries that process uses, even though a share D library is just loaded into memory once regardless of what many processes use, so using RSS to measure the memory information the process uses is not particularly accurate.

PSS -proportional Set size actual physical memory used (proportional allocation of memory consumed by shared libraries). PSS is a very useful number because if the PSS for all processes in the system is summed together, which is a good repre Sentation for the total memory usage in the system, so the use of PSS to measure the program occupies a relatively small error.

USS -the Unique Set size process consumes the physical memory alone (does not contain the memory occupied by the shared library). USS is an extremely useful number because it indicates the true incremental cost of running a particular process so with USS Description into The fluctuation of memory and the peak value of the process are significant.

The following relationship Vss>=rss>=pss>=uss generally exists .

If you want to get the memory information of a process, using Procrank is a good choice, but many Android systems do not support this command, HTC phone part of the native system support, such as G3 2.2.1rom.

2. Top command

Enter the command line adb shell top , as shown in: Lists the CPU and memory consumption of the top* process, sorted by default in descending CPU usage. Top can get VSS and RSS information for the process, command continuous monitoring, so personally feel this is a good way to quickly view the process memory and CPU.

3. PS command

The PS command can get the application's Vsize (VSS) and rss,ps to be an instant state of the app, without having to exit the acknowledgement, so it works better on automation scripts. ps | grep appNamedirectly outputs the memory information corresponding to the appname process.

4. Dumpsys Meminfo

Dumpsys is used to give information about all the apps in the phone, and it also gives the status of the phone. Use the following command to view the memory usage of the program: adb shell Dumpsys meminfo $package _name or $pid//Use the program's package name or process ID

Android program memory is divided into 2 parts: native and Dalvik,dalvik are the Java heaps we normally call, the objects we create are assigned here, and bitmap are allocated directly on native, and the limit for memory is native+ Dalvik cannot exceed the maximum limit. Android program memory is generally limited to 16M and 24M

Size: Total memory Size (KB). Allocated: Represents the amount of memory used (KB), free: Indicates the amount of memory remaining (KB) Privatedirty: unshared, and cannot be paged out (can not be paged to disk). Similar to the USS, but in practice, it was found that they still had subtle differences that were not yet understood. Shareddirty: Referring to Privatedirty I think it should mean the size of the memory that is shared and cannot be paged out (can not be paged to disk). For example, the small object that Linux buffers in order to increase the allocated memory speed, even if all the processes that share it end, the memory is not released, it just goes back to the buffer.
5. adb shell cat /proc/meminfo

This method can only obtain the approximate usage of the whole memory of the system.

Memtotal: The total amount of memory available to the system and the user (it is smaller than the actual physical memory, as there is some memory to use for radio, DMA buffers, etc.). Memfree: The remaining available memory size. This value is relatively large here, in fact, the average Android system is usually very small, because we try to keep the process running, which consumes a lot of memory.

Cached: The system is used for memory such as file buffering. Usually systems need 20MB to avoid bad paging states.

6. cat /proc/$pid/status

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.