Android Memory limit Java Virtual machine has 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
Initial memory allocated after app startup
Maximum memory limit for a single Java virtual machine, exceeding this value will result in Oom
Some memory limitations of Xiaomi 2S
#查看单个应用程序最大内存限制[email protected] ~$ adb shell getprop|grep heapgrowthlimit|[dalvik.vm.heapgrowthlimit]: [96m]#应用启动后分配的初始内存[email protected] ~$ adb shell getprop|grep dalvik.vm.heapstartsize|[dalvik.vm.heapstartsize]: [8m]#单个java虚拟机最大的内存限制[email protected] ~$ 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 //使用程序的包名或者进程id
View memory usage of the Shrimp Music app
[email protected] ~$ adb shell dumpsys meminfo fm.xiami.mainApplications 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 18 691 10825 7866 Cursor 0 0 0 ashmem 0 0 0 Other Dev 4 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 + other Mmap 204 Unknown 808 540 804 Total 7722 16980 4232 20667 12402 8092 Objects Views:0 viewrootimpl:0 appcontexts:5 activities:0 Ets:3 assetmanagers:3 Local binders:5 Proxy binders:13 death Recipie nts:0 OpenSSL sockets:0 SQL memory_used:0 pagecache_overflow:0 Mallo c_size:0
where size is the memory that is needed, and allocated is allocated memory, the corresponding 2 columns are native and Dalvik, respectively, When the total column exceeds the maximum limit for a single program's memory, Oom is likely to occur.
Shared Private Heap 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
The CPU Usage 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. // 最多显示多少个进程 -n num Updates to show before exiting. // 刷新次数 -d num Seconds to wait between updates. // 刷新间隔时间(默认5秒) -s col Column to sort by <cpu,vss,rss,thr> // 按哪列排序 -t Show threads instead of processes. // 显示线程信息而不是进程 -h
As an example:
View the usage of the top 5 process Cups
[email protected] ~$ adb shell top -m 5 -s cpu
User 33%, System 8%, IOW 0%, IRQ 0%User 340 + Nice 2 + Sys 83 + Idle 596 + IOW 6 + IRQ 0 + SIRQ 2 = 1029 PID PR CPU% S #THR VSS RSS PCY UID Name27256 1 12% S 37 852340K 220296K fg u0_a25 fm.xiami.main 517 0 6% S 100 842940K 118832K fg system system_server 174 0 4% S 13 66532K 14000K fg media /system/bin/mediaserver27767 0 2% S 11 673928K 50516K bg u0_a58 com.moji.mjweather 171 0 1% S 13 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 utilization: User process System Process IO W io wait time IRQ hard Interrupt Time CPU usage (refers to a minimum time that occupies time in the chip, Unit jiffies. or refers to the number of processes): The user is in the running time of the client state, does not contain the priority value is negative process nice priority negative process occupied by the CPU time Sys is in the kernel mentality of the run time Idle other than the IO wait time wait time IOW io wait time IRQ Hard Interrupt Time SIRQ soft Interrupt Time Process properties: PID Process ID CPU% current instantaneous in the system uses the state of the CPU occupancy s process, where s represents 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 Dummy memory consumption (contains memory occupied by shared library) RSS resident Set size actually uses physical memory (contains memory occupied by shared library) PCY Ooxx, do not know what the UID The user ID running the current process name name Android.process.media/PS: Memory footprint has the following rules: VSS >= RSS >= pss >= USS//PSS proportional Se T size actual physical memory used (proportional allocation shared library occupies memory)//USS Unique Set Size process alone occupies physical memory (does not contain memory occupied by shared library)
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
[email protected] ~$ adb shell procrank |grep xiami
You can also use adb shell Dumpsys meminfo If you are just viewing PSS
[email protected] ~$ adb shell dumpsys meminfo fm.xiami.main|grep TOTAL TOTAL 143070 15312 130020 135179 122279 12667
Warm tips:
Before taking the memory data before you can determine whether the phone root, if root to take the USS better, if not root to take PSS is also possible.
Public account: WIRELESSQA
About
Author: Bi Xiaobong | Old bi e-mail: [email protected]
Weibo: @WirelessQA Blog: HTTP://BLOG.CSDN.NET/WIRELESSQA