Android memory consumption: Vss/rss/pss/uss

Source: Internet
Author: User

VSS-Virtual Set Size virtualized memory consumption (contains memory consumed by shared libraries)

is not the actual memory occupied by the current application process.

    

The principle of memory allocation

From the operating system perspective, the process allocates memory in two ways, with two system invocations:BRK and mmap (regardless of shared memory).

1, BRK is the data segment (. data) The highest address pointer _edata to the high address of the push;

2, Mmap is in the virtual address space of the process (heap and the middle of the stack, called the file map area ) to find a piece of free virtual memory .

Both of These methods allocate virtual memory and no physical memory is allocated . The first time you access the allocated virtual address space,

a missing pages interrupt occurred, the operating system is responsible for allocating physical memory, and then establishing a mapping relationship between virtual memory and physical memory.

In the standard C library, Malloc/free function allocations are provided to release memory, which is implemented by brk,mmap,munmap these system calls.

situation one,malloc less than 128k of memory, using BRK to allocate memory, _edata to high address push (only allocate virtual space, does not correspond to physical memory (so there is no initialization),

When the first read/write data causes the kernel page fault to be interrupted, the kernel allocates the corresponding physical memory and then the virtual address space establishes the mapping relationship.

Scenario Two,malloc greater than 128k of memory, use MMAP to allocate memory, find a free memory allocation between heap and stack (corresponding to independent memory, and initialized to 0)

RSS-resident Set Size actually uses physical memory (contains memory consumed by shared libraries)

This contains the physical memory occupied by the shared library, even if the shared library is used by multiple processes

PSS-Proportional Size actual physical memory used (proportional allocation of memory consumed by shared libraries)

Proportional to the memory occupied by the shared library, such as 9k shared libraries are used by 3 processes, the current process is accounted for

The size used is calculated as 9/3k, which is 3k

USS-Unique Set Size process consumes physical memory alone (does not contain memory consumed by shared libraries)

Current process, all current physical memory in use

Top | grep app Name

PS | grep app Name

Procrank | grep app Name

General Android does not have this command, need to download one, or download the source code, compile and install.

Dumpsys meminfo App Name

The first two commands can only be traced to VSS RSS memory consumption information

The following two commands can be used to detect the memory footprint of PSS USS.

Dumpsys Meminfo can find out how much memory native and Dalvik respectively occupy

Dumpsys is used to give information about all the apps in the phone, and it also gives the status of the phone.

Dumpsys [Option]

Meminfo Display Memory Information

Cpuinfo Displaying CPU information

Account Displays accounts information

Activity shows all the activities information.

window shows the keyboard, Windows, and their relationships

WiFi Display WiFi information

Android memory consumption: Vss/rss/pss/uss

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.