Android System Detection Program memory footprint various methods _android

Source: Internet
Author: User
Tags memory usage

1. Check System total Memory

Copy Code code as follows:

LIUHX@UC ~ $ adb Shell Cat/proc/meminfo
memtotal:840868 KB
memfree:457344 KB
buffers:1744 KB
cached:203064 KB
swapcached:0 KB
active:234932 KB
inactive:129644 KB
Active (anon): 170292 KB
Inactive (anon): 0 KB
Active (file): 64640 KB
Inactive (file): 129644 KB
unevictable:0 KB
mlocked:0 KB
swaptotal:0 KB
swapfree:0 KB
dirty:0 KB
writeback:0 KB
anonpages:159820 KB
mapped:97916 KB
slab:7808 KB
sreclaimable:2920 KB
sunreclaim:4888 KB
pagetables:3516 KB
nfs_unstable:0 KB
bounce:0 KB
writebacktmp:0 KB
commitlimit:420432 KB
committed_as:1295272 KB
vmalloctotal:122880 KB
vmallocused:16508 KB
vmallocchunk:76804 KB

The first line of Memtotal is total memory. is not generally equal to the value of mobile phone advertised. Said is 2G memory of the phone, will be around 1.8G

2. Check the various types of memory footprint of a program

The Dumpsys Meminfo package name is available. Do not know the package name, you can use the PS command to get all the running programs, including the PID. Take your own browser for example:

Copy Code code as follows:

LIUHX@UC ~ $ adb shell Dumpsys meminfo com.android.browser
Applications Memory Usage (KB):
uptime:23140065 realtime:23140065

* * Meminfo in PID 939 [com.android.browser] * *
Shared Private Heap Heap Heap
Pss Dirty Dirty Size Alloc Free
------   ------   ------   ------   ------   ------
Native 7111 748 7048 8964 8634 329
Dalvik 7338 5096 6892 7568 7041 527
Cursor 0 0 0
Ashmem 276 0 276
Other Dev 4 0 0
. So mmap 5050 1728 252
. Jar Mmap 0 0 0
. apk mmap 418 0 0
. TTF mmap 439 0 0
. Dex Mmap 0 0 0
Other Mmap 2320 16 24
Unknown 5173 12 5172
Total 28129 7600 19664 16532 15675 856

Objects
views:104 viewrootimpl:1
Appcontexts:4 activities:1
Assets:2 Assetmanagers:2
Local binders:15 Proxy binders:19
Death recipients:0
OpenSSL sockets:0

Sql
memory_used:1468
pagecache_overflow:899 malloc_size:168

DATABASES
Pgsz Dbsz lookaside (b) Cache dbname
4 1180 54/55/9/data/data/com.android.browser/databases/browser2.db
4 1180 1/60/2/data/data/com.android.browser/databases/browser2.db (2)
4 1180 90/23/7/data/data/com.android.browser/databases/browser2.db (1)
4 0/15/1/data/data/com.android.browser/databases/webview.db

Asset Allocations
zip:/system/app/browser.apk:/resources.arsc:881k

The output of Dumpsys may be different in different versions of the Android system.

Where PSS Total is a program-occupied PSS.

3. Check program status

Copy Code code as follows:

LIUHX@UC ~ $ adb Shell Cat/proc/939/status
Name:android.browser
State:s (sleeping)
tgid:939
pid:939
ppid:38
tracerpid:0
uid:10013 10013 10013 10013
gid:10013 10013 10013 10013
fdsize:256
groups:1015 1028 3003 50013
vmpeak:215504 KB
vmsize:206780 KB
vmlck:0 KB
vmhwm:52108 KB
vmrss:47748 KB
vmdata:53616 KB
vmstk:84 KB
Vmexe:8 KB
vmlib:29300 KB
vmpte:156 KB
Threads:29
sigq:0/6656
sigpnd:0000000000000000
shdpnd:0000000000000000
sigblk:0000000000001204
sigign:0000000000000000
Sigcgt:00000002000094e8
capinh:0000000000000000
capprm:0000000000000000
capeff:0000000000000000
Capbnd:fffffffffffffeff
voluntary_ctxt_switches:451
nonvoluntary_ctxt_switches:3563

Vmrss is a program-consumed RSS

4. Check the memory footprint of each part of the program.

Copy Code code as follows:

Cat/proc/939/smaps

The output of this command is very long, and here is a partial result:
Copy Code code as follows:

4b399000-4b39b000 r--p 0001d000 1f:00 560/system/lib/libglesv1_enc.so
Size:8 KB
Rss:8 KB
Pss:8 KB
shared_clean:0 KB
shared_dirty:0 KB
private_clean:0 KB
Private_dirty:8 KB
Referenced:8 KB
swap:0 KB
Kernelpagesize:4 KB
Mmupagesize:4 KB
4b39b000-4b39c000 rw-p 0001f000 1f:00 560/system/lib/libglesv1_enc.so
Size:4 KB
Rss:4 KB
Pss:4 KB
shared_clean:0 KB
shared_dirty:0 KB
private_clean:0 KB
Private_dirty:4 KB
Referenced:4 KB
swap:0 KB
Kernelpagesize:4 KB
Mmupagesize:4 KB

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.