Android uses Procrank and Dumpsys meminfo to analyze memory usage

Source: Internet
Author: User

If you want to see memory usage for all processes, you can use the command Procrank, Dumpsys meminfo to view, and of course only filter out a process such as: Dumpsys Meminfo | Grep-i Phone

First look at Procrank.

sh-4.2# procrank PID Vss Rss Pss Uss cmdline 1078 59840K 59708K 42125K 39344K com.csr.BTApp 2683 59124K 59040K 37960K 33032K com.android.launcher 1042 51572K 51488K 35686K 33604K android.process. Acore 782 32808K 32748K 16775K 14716K system_server 667 20560K 17560K 12739K 8940K/SYSTEM/BIN/SURFAC Eflinger 851 30124K 30036K 12085K 7996K com.android.systemui 2999 27680K 27596K 9929K 7040K com.baid U.input 959 20764K 20676K 5522K 3788K com.android.phone 3468 21892K 21800K 4591K 1920K COM.APICAL.D Reamthemetime 982 19880K 19792K 4438K 2644K com.csr.csrservices 668 19592K 19480K 3525K 1360K Zygo Te 670 2960K 2960K 2407K 2356k/system/bin/mediaserver 663 1784K 1784K 1209K 1116k/system/bin /synergy_service 756 3404K 1348K 1133K 1124k/usr/bin/gpsexe 669 1468K 1468K 959K 928k/syst   Em/bin/drmserver 675  692K 692K 692K 692k/bin/sh 758 1060K 1060K 630K 604k/system/bin/audiotransfer 3482 65     6K 652K 456K 444K procrank 664 664K 664K 403K 392k/system/bin/netd 658 584K 584K     331K 320k/system/bin/vold 666 548K 548K 270K 256k/system/bin/rild 671 416K 412K 212K 204k/system/bin/dbus-daemon 673 336K 332K 170K 164k/system/bin/keystore 1 164K 16  4K 144K 144k/init 674 152K 152K 136K 136k/sbin/adbd 662 312K 312K 112K 104K  /SYSTEM/BIN/DVDD 672 328K 324K 109K 100k/system/bin/installd 657 268K 264K 102K 96K /system/bin/servicemanager 649 84K 84K 84K 84k/sbin/ueventd 665 260K 256K 83K 7 6k/system/bin/debuggerd------------------195031K 163724K Total ram:480380k Total, 3624K free, 732K buffers, 299788K cached, 264844K shmem, 7632K Slab 
From the above printing can be seen, generally speaking, memory consumption size has the following rules: VSS >= RSS >= PSS >= USS
Vss-virtual Set Size Virtual memory consumption (contains memory consumed by shared libraries) is a fully accessible address space for a single process
Rss-resident Set Size actual use of physical memory (containing memory consumed by shared libraries) is the actual amount of memory consumed by a single process, and for a single shared library, the actual shared library will only be loaded once in memory, regardless of the number of processes used.
Pss-proportional Set Size Actual physical memory used (proportional allocation of memory consumed by shared libraries)
Uss-unique the Set size process consumes the physical memory alone (does not contain the memory occupied by the shared library) The USS is a very useful number because it reveals the true memory increment size of running a particular process. If the process is terminated, USS is the amount of memory actually returned to the system.
USS is the best number to detect when a process begins to have a suspected memory leak. Suspect a program has a memory leak can see whether this value has been increased

Use Dumpsys meminfo to view memory information

sh-4.2# Dumpsys meminfoapplications Memory Usage (KB): uptime:3353863 realtime:3353850total PSS by process:41743 KB: COM.CSR.BTAPP (PID 1078) 36924 KB:com.android.launcher (PID 2683) 35452 KB:android.process.acore (PID 1042) 160 94 Kb:system (PID 782) 11609 KB:com.android.systemui (PID 851) 8564 KB:com.baidu.input (PID 2999) 5298 Kb:c     Om.android.phone (PID 959) 4443 KB:com.apical.dreamthemetime (PID 4448) 4203 kB:com.csr.csrservices (PID 982) 4130 KB:com.apical.apicalradio (PID 4518) Total PSS by OOM adjustment:16094 Kb:system 16094 kb:syste M (PID 782) 21110 kb:persistent 11609 kB:com.android.systemui (PID 851) 5298 KB:com.and  Roid.phone (PID 959) 4203 kB:com.csr.csrservices (PID 982) 36924 Kb:foreground 36924 KB: Com.android.launcher (PID 2683) 85759 kb:perceptible 41743 kB:com.csr.BTApp (PID 1078) 3 5452 kB:android.process. Acore (PID 1042) 8564 KB:com.baidu.input (PID 2999) 4443 kb:a Services 4443 KB:COM.A  Pical.dreamthemetime (PID 4448) 4130 kb:background 4130 kB:com.apical.apicalradio (PID 4518) Total PSS     by category:56020 Kb:dalvik 30214 kb:other Dev 27716 kb:native 24504 kb:cursor 13198 Kb:unknown 7723 kb:other mmap 6895 KB:. So mmap 1232 KB:. APK mmap 888 KB:. DEX Mmap-KB:. TTF mmap kb : Ashmem 0 KB:. Jar Mmaptotal pss:168460 kb
Print a program memory information, write the package name, such as: Com.android.launcher

sh-4.2# dumpsys meminfo com.android.launcherApplications Memory Usage (KB): uptime:4497753 realtime:4497741** Meminfo in PID 2683 [Com.android.launcher] * * Shared Private heap Heap P SS Dirty Dirty Size Alloc free------------------------------------N      ative 2144 988 2040 8636 5124 1699 Dalvik 9481 8292 8644 13639 13335                               304 Cursor 0 0 0 Ashmem 2 4 0 Other Dev 4 0. So mmap 922 1892 29        2. Jar Mmap 0 0 0. apk mmap 90      0 0. TTF mmap 0 0 0. Dex mmap 300 0 0                              Other mmap 1634 Unknown 1830               580 1772 Total 16407 11792 12860 22275 18459 2003 Objects              views:146 viewrootimpl:1 appcontexts:374 activities:1 Assets:4 assetmanagers:4 Local binders:13 Proxy binders:23 Dea Th recipients:1 OpenSSL sockets:0 SQL heap:59 memory_used:59 P Agecache_overflow:1 malloc_size:46 DATABASES pgsz dbsz lookaside (b) Cache Db Name 1 179 2/11/2 launcher.db Asset Allocations Zip:/system/app/launcher2.apk:/re sources.arsc:340k zip:/system/app/mediacenter.apk:/resources.arsc:604k
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, of course, there are 24M.
From the above information for the analysis of memory leaks, memory overflow has a great effect, from the above information can be seen that the application occupies native and Dalvik, when total 16407 11792 12860 22275 18459 2003 exceeded the maximum memory limit, an oom error occurs.
There's a lot dumpsys can do.

Dumpsys [Options]               meminfo display memory information               cpuinfo display CPU Information account               display accounts Information               activity Show all activities information               window displays the keyboard, Windows and their relationships               WiFi displays wifi information
Reference Document: Http://www.cnblogs.com/qianxudetianxia/archive/2012/05/14/2497073.html

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.