Android memory and CPU performance test

Source: Internet
Author: User

Android Memory limit
Java virtual machines have a limit on memory usage

ADB shell enters the phone, this parameter is recorded in/system/build.prop, if you want to view directly can use ADB shell Getprop

Maximum memory limit for a single application, exceeding this value will result in Oom
Dalvik.vm.heapgrowthlimit
Initial memory allocated after app startup
Dalvik.vm.heapstartsize
Maximum memory limit for a single Java virtual machine, exceeding this value will result in Oom
Dalvik.vm.heapsize
Some memory limitations of Xiaomi 2S

#查看单个应用程序最大内存限制
ADB Shell Getprop|grep Heapgrowthlimit
| [Dalvik.vm.heapgrowthlimit]: [96m]

#应用启动后分配的初始内存
ADB Shell Getprop|grep dalvik.vm.heapstartsize
| [Dalvik.vm.heapstartsize]: [8m]

#单个java虚拟机最大的内存限制
ADB Shell Getprop|grep dalvik.vm.heapsize


| [Dalvik.vm.heapsize]: [384m]
Android Memory usage
Android program memory is generally limited to 16M, of course there are 24M, while the 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.

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
View memory usage of the Shrimp Music app

adb shell Dumpsys meminfo fm.xiami.main


Applications Memory Usage (KB):
uptime:71696500 realtime:98283758

* * Meminfo in PID 17340 [Fm.xiami.main] * *
Shared Private Heap Heap
Pss Dirty Dirty Size Alloc Free
------   ------   ------   ------   ------   ------
Native 0 0 0 1976 1577 226
Dalvik 2973 13956 2712 18691 10825 7866
Cursor 0 0 0
Ashmem 0 0 0
Other Dev 4 44 0
. So mmap 894 2320 604
. Jar Mmap 0 0 0
. APK mmap 123 0 0
. TTF Mmap 0 0 0
. Dex mmap 2716 0 16
Other MMAP 204 120 96
Unknown 808 540 804
Total 7722 16980 4232 20667 12402 8092

Objects
views:0 viewrootimpl:0
Appcontexts:5 activities:0
Assets:3 Assetmanagers:3
Local binders:5 Proxy binders:13
Death recipients:0
OpenSSL sockets:0

Sql
memory_used:0
pagecache_overflow:0 malloc_size:0
Where size is the required memory, and allocated is allocated memory, the corresponding 2 columns are native and Dalvik, and when the total is the maximum limit of the individual program memory, Oom is likely to occur.

Shared Private Heap Heap
Pss Dirty Dirty Size Alloc Free
------   ------   ------   ------   ------   ------
Native 0 0 0 1976 1577 226
Dalvik 2973 13956 2712 18691 10825 7866
Total 7722 16980 4232 20667 12402 8092


CPU Usage
The top command is as follows:
ADB shell
$ top-h
Top-h
Usage:top [-M Max_procs] [-N iterations] [-D delay] [-s sort_column] [-t] [-h]
-M num Maximum number of processes to display. Maximum number of processes to display
-N num Updates to show before exiting. Number of refreshes
-D num Seconds to wait between updates. Refresh Interval Time (default 5 seconds)
-S Col column to sort by <cpu,vss,rss,thr>//sorted by which column
-T Show threads instead of processes. displaying thread information instead of processes
-H Display this help screen. Show Help Document
$ top-n 1
Top-n 1
As an example:
View the usage of the top 5 process Cups

ADB shell top-m 5-s CPU

User 33%, System 8, IOW 0, IRQ 0%
User 340 + Nice 2 + Sys + Idle 596 + IOW 6 + IRQ 0 + sirq 2 = 1029

PID PR CPU% S #THR VSS RSS PCY UID Name
27256 1 12% S PNS 852340K 220296K FG U0_a25 Fm.xiami.main
517 0 6% S 842940K 118832K FG System System_server
174 0 4% S 66532K 14000K FG Media/system/bin/mediaserver
27767 0 2% S 673928K 50516K BG u0_a58 com.moji.mjweather
171 0 1% S 97904K 51964K FG System/system/bin/surfaceflinger


Log Description:
User 35%, System 13%, IOW 0, IRQ 0%//CPU Usage
User 109 + Nice 0 + Sys + Idle 156 + IOW 0 + IRQ 0 + SIRQ 1 = 306//CPU Usage

PID CPU% S #THR VSS RSS PCY UID Name//Process Properties
XX xx% x xx xx xx xx xx xx

CPU Usage:
User process
System process
IOW io Wait Time
IRQ Hard Interrupt Time

CPU usage (refers to the amount of time in a minimum time slice, unit jiffies. or the number of processes that are accounted for):
User is in the run time of the client state and does not contain a negative process with a priority value
CPU time consumed by a process with a negative priority value
Sys is in the running time of the nuclear mentality
Idle wait time other than IO wait time
IOW io Wait Time
IRQ Hard Interrupt Time
SIRQ Soft Interrupt Time

Process properties:
The ID of the PID process in the system
CPU% current instantaneous so use CPU usage
The state of the S process, where s indicates hibernation, R is running, Z represents a zombie state, and N indicates that the process precedence value is negative.
The number of threads currently used by the #THR program
VSS Virtual Set Size virtualized memory consumption (contains memory consumed by shared libraries)
RSS resident Set Size actually uses physical memory (contains memory consumed by shared libraries)
PCY Ooxx, don't know what
UID the user ID that runs the current process
Name program Names Android.process.media

PS: Memory consumption size has the following rules: VSS >= RSS >= PSS >= USS
PSS Proportional Set Size actual physical memory used (proportional allocation of memory consumed by shared libraries)
USS Unique Set Size process consumes physical memory alone (does not contain memory consumed by shared libraries)
Warm tips:

We generally observe the USS to reflect the memory usage of a process, and the size of the USS represents the amount of memory that is being used by the process, which is completely recycled after it has been killed.

VSS and RSS have little value in viewing a process's own memory state because they contain the memory usage of the shared library, and often the shared library's resource footprint is large, diluting the creation of memory fluctuations on the process itself. PSS, in proportion, divides the shared memory by a process that consumes the shared memory.

So

View USS and PSS can use the ADB shell Procrank if the phone requires root

adb shell Procrank |grep Xiami
You can also use adb shell Dumpsys meminfo If you are just viewing PSS

adb shell Dumpsys meminfo fm.xiami.main|grep Total
Total 143070 15312 130020 135179 122279 12667

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.