标签:android class blog code java http
如果你想查看所有进程的内存使用情况,可以使用命令procrank、dumpsys meminfo查看,当然也只可以过滤出某个进程如:dumpsys meminfo | grep -i phone
先来看下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/surfaceflinger 851 30124K 30036K 12085K 7996K com.android.systemui 2999 27680K 27596K 9929K 7040K com.baidu.input 959 20764K 20676K 5522K 3788K com.android.phone 3468 21892K 21800K 4591K 1920K com.apical.dreamthemetime 982 19880K 19792K 4438K 2644K com.csr.csrservices 668 19592K 19480K 3525K 1360K zygote 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 /system/bin/drmserver 675 692K 692K 692K 692K /bin/sh 758 1060K 1060K 630K 604K /system/bin/audiotransfer 3482 656K 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 164K 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 76K /system/bin/debuggerd ------ ------ ------ 195031K 163724K TOTAL RAM: 480380K total, 3624K free, 732K buffers, 299788K cached, 264844K shmem, 7632K slab从以上打印可以看出,一般来说内存占用大小有如下规律:VSS >= RSS >= PSS >= USS
使用dumpsys meminfo查看内存信息
sh-4.2# dumpsys meminfo Applications Memory Usage (kB): Uptime: 3353863 Realtime: 3353850 Total PSS by process: 41743 kB: com.csr.BTApp (pid 1078) 36924 kB: com.android.launcher (pid 2683) 35452 kB: android.process.acore (pid 1042) 16094 kB: system (pid 782) 11609 kB: com.android.systemui (pid 851) 8564 kB: com.baidu.input (pid 2999) 5298 kB: com.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: system (pid 782) 21110 kB: Persistent 11609 kB: com.android.systemui (pid 851) 5298 kB: com.android.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) 35452 kB: android.process.acore (pid 1042) 8564 kB: com.baidu.input (pid 2999) 4443 kB: A Services 4443 kB: com.apical.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 36 kB: .ttf mmap 34 kB: Ashmem 0 kB: .jar mmap Total PSS: 168460 kB打印某个程序内存信息,把包名写上,如:com.android.launcher
sh-4.2# dumpsys meminfo com.android.launcher Applications Memory Usage (kB): Uptime: 4497753 Realtime: 4497741 ** MEMINFO in pid 2683 [com.android.launcher] ** Shared Private Heap Heap Heap Pss Dirty Dirty Size Alloc Free ------ ------ ------ ------ ------ ------ Native 2144 988 2040 8636 5124 1699 Dalvik 9481 8292 8644 13639 13335 304 Cursor 0 0 0 Ashmem 2 4 0 Other dev 4 20 0 .so mmap 922 1892 292 .jar mmap 0 0 0 .apk mmap 90 0 0 .ttf mmap 0 0 0 .dex mmap 300 0 0 Other mmap 1634 16 112 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 Death Recipients: 1 OpenSSL Sockets: 0 SQL heap: 59 MEMORY_USED: 59 PAGECACHE_OVERFLOW: 1 MALLOC_SIZE: 46 DATABASES pgsz dbsz Lookaside(b) cache Dbname 1 179 55 2/11/2 launcher.db Asset Allocations zip:/system/app/Launcher2.apk:/resources.arsc: 340K zip:/system/app/MediaCenter.apk:/resources.arsc: 604KAndroid程序内存被分为2部分:native和dalvik,dalvik就是我们平常说的java堆,我们创建的对象是在这里面分配的,而bitmap是直接在native上分配的,对于内存的限制是 native+dalvik 不能超过最大限制。Android程序内存一般限制在16M,当然也有24M的。
dumpsys [options] meminfo 显示内存信息 cpuinfo 显示CPU信息 account 显示accounts信息 activity 显示所有的activities的信息 window 显示键盘,窗口和它们的关系 wifi 显示wifi信息参考文档:http://www.cnblogs.com/qianxudetianxia/archive/2012/05/14/2497073.html
Android使用procrank和dumpsys meminfo分析内存占用情况,布布扣,bubuko.com
Android使用procrank和dumpsys meminfo分析内存占用情况
标签:android class blog code java http
原文地址:http://blog.csdn.net/deng0zhaotai/article/details/34848929