Android procrank && dumpsys meminfo使用详解

procrank:
</pre><pre code_snippet_id="1694739" snippet_file_name="blog_20160524_3_6418082" name="code" class="html">/data/anr # procrank                                               
  PID       Vss      Rss      Pss      Uss  cmdline
29024    83948K   45468K   44255K   43832K  /system/bin/mediaserver
30075   575572K   57324K   38586K   34656K  xxxxxxxxxxxxxx
27110   588816K   33180K   18343K   15408K  system_server
30137   534808K   26660K   10214K    6776K  com.android.settings
29137   535184K   24640K    8162K    5080K  xxxxxxxxxx
30168   517332K   19044K    5440K    3588K  xxxxxxxxxxxxx
27320   511604K   14344K    3746K    2760K  xxxxxxxxxxx
27384   523244K   12592K    2895K    2184K  xxxxxxxxxxxxxxxx
27518   511928K   12868K    2699K    1920K  xxxxxxxxxxxxxxx
29626   508920K   14404K    2458K    1188K  com.android.defcontainer
27372   512324K   11656K    2317K    1672K  xxxxxxxxxx
27278   517960K   11396K    2282K    1664K  xxxxxxxxx
29655   510040K   13676K    2182K    1080K  xxxxxxxxxxxxxxxxxx
27265   510136K   11596K    1963K    1292K  xxxxxxxxxxx
27532   512304K   11184K    1829K    1192K  xxxxxxxxxxxxxxx
  118    63300K    3136K    1754K    1508K  /system/bin/surfaceflinger
27167   514816K   11032K    1700K    1076K  com.android.keyguard
27253   513092K   10892K    1424K     784K  com.android.systemui
26845   502516K   11592K    1415K     576K  zygote
27567   509688K   10752K    1327K     664K  android:userExpericenceService
30198     1884K    1356K    1147K    1124K  procrank
29413     7120K     820K     467K     336K  adb
  127     3744K     584K     457K     452K  /system/bin/sdcard
26844     9816K     604K     330K     300K  /system/bin/netd
    1      696K     364K     250K     176K  /init
  112      940K     344K     240K     236K  /system/bin/sh
  134     6656K     228K     212K     212K  /sbin/adbd
  117     1084K     360K     149K     132K  /system/bin/debuggerd
  111     1428K     128K     124K     124K  /sbin/healthd
  122      996K     280K     100K      92K  /system/bin/installd
   97      600K     152K      76K       4K  /sbin/ueventd
  115     6264K     196K      73K      64K  /system/bin/displayd
  113     1004K     128K      58K      56K  /system/bin/servicemanager
  114     5696K     152K      25K      16K  /system/bin/vold
27333     1024K     236K      16K       4K  /system/bin/dhcpcd
  124     3352K     168K      14K       8K  /system/bin/keystore
  120     9568K      36K       8K       8K  /system/bin/drmserver
  126      968K      28K       4K       4K  /system/bin/bmd
                           ------   ------  ------
                          158756K  132248K  TOTAL

RAM: 504440K total, 39296K free, 5468K buffers, 173248K cached, 1088K shmem, 24568K slab

从以上打印可以看出,一般来说内存占用大小有如下规律:VSS >= RSS >= PSS >= USS
VSS - Virtual Set Size 虚拟耗用内存(包含共享库占用的内存)是单个进程全部可访问的地址空间
RSS - Resident Set Size 实际使用物理内存(包含共享库占用的内存)是单个进程实际占用的内存大小,对于单个共享库, 尽管无论多少个进程使用,实际该共享库只会被装入内存一次。
PSS - Proportional Set Size 实际使用的物理内存(比例分配共享库占用的内存)
USS - Unique Set Size 进程独自占用的物理内存(不包含共享库占用的内存)USS 是一个非常非常有用的数字, 因为它揭示了运行一个特定进程的真实的内存增量大小。如果进程被终止, USS 就是实际被返还给系统的内存大小。
USS 是针对某个进程开始有可疑内存泄露的情况,进行检测的最佳数字。怀疑某个程序有内存泄露可以查看这个值是否一直有增加



dumpsys meminfo:


<span style="font-size:32px;">xxx:/data/anr # dumpsys meminfo                                        
Applications Memory Usage (kB):
Uptime: 86119812 Realtime: 86119812

Total PSS by process:
    44177 kB: mediaserver (pid 29024)
     1698 kB: com.android.keyguard (pid 27167)
     1365 kB: com.android.systemui (pid 27253)
     1336 kB: android:userExpericenceService (pid 27567)
     1332 kB: zygote (pid 26845)
      927 kB: surfaceflinger (pid 118)
      464 kB: adb (pid 29413)
      455 kB: sdcard (pid 127)
      337 kB: netd (pid 26844)
      250 kB: /init (pid 1)
      249 kB: dumpsys (pid 30219)
      238 kB: sh (pid 112)
      212 kB: adbd (pid 134)
      145 kB: debuggerd (pid 117)
      136 kB: displayd (pid 115)
      124 kB: healthd (pid 111)
       98 kB: installd (pid 122)
       92 kB: ueventd (pid 97)
       92 kB: vold (pid 114)
       57 kB: servicemanager (pid 113)
       12 kB: keystore (pid 124)
       12 kB: dhcpcd (pid 27333)
        8 kB: drmserver (pid 120)
        4 kB: bmd (pid 126)

Total PSS by OOM adjustment:
    49421 kB: Native
               44177 kB: mediaserver (pid 29024)
                1332 kB: zygote (pid 26845)
                 927 kB: surfaceflinger (pid 118)
                 464 kB: adb (pid 29413)
                 455 kB: sdcard (pid 127)
                 337 kB: netd (pid 26844)
                 250 kB: /init (pid 1)
                 249 kB: dumpsys (pid 30219)
                 238 kB: sh (pid 112)
                 212 kB: adbd (pid 134)
                 145 kB: debuggerd (pid 117)
                 136 kB: displayd (pid 115)
                 124 kB: healthd (pid 111)
                  98 kB: installd (pid 122)
                  92 kB: ueventd (pid 97)
                  92 kB: vold (pid 114)
                  57 kB: servicemanager (pid 113)
                  12 kB: keystore (pid 124)
                  12 kB: dhcpcd (pid 27333)
                   8 kB: drmserver (pid 120)
                   4 kB: bmd (pid 126)
    18633 kB: System
               18633 kB: system (pid 27110)
     5811 kB: Persistent
               
                1698 kB: com.android.keyguard (pid 27167)
    37614 kB: Foreground
               33227 kB: xxx (pid 30075 / activities)
                4387 kB: xxxxxxx (pid 27384)
     1365 kB: Visible
                1365 kB: com.android.systemui (pid 27253)
    11446 kB: B Services
               x
                1760 kB: xxx (pid 27532)
                1336 kB: android:userExpericenceService (pid 27567)
    27964 kB: Cached
               10366 kB: com.android.settings (pid 30137)
                7962 kB: xxxxxxx (pid 29137)
                5214 kB: xxx (pid 30168)
                2344 kB: com.android.defcontainer (pid 29626)
                2078 kB: xxxxxxxxxxxxx (pid 29655)

Total PSS by category:
    51370 kB: Native
    40078 kB: Dalvik
    18818 kB: .so mmap
    17530 kB: .dex mmap
    15636 kB: Dalvik Other
     2718 kB: .apk mmap
     1775 kB: .ttf mmap
     1664 kB: Stack
     1350 kB: Other mmap
     1187 kB: Unknown
      120 kB: Other dev
        8 kB: .jar mmap
        0 kB: Cursor
        0 kB: Ashmem
        0 kB: code mmap
        0 kB: image mmap
        0 kB: Graphics
        0 kB: GL
        0 kB: Memtrack

Total RAM: 504440 kB
 Free RAM: 240808 kB (27964 cached pss + 175652 cached + 37192 free)
 Used RAM: 155722 kB (124290 used pss + 5776 buffers + 1088 shmem + 24568 slab)
 Lost RAM: 107910 kB
     ZRAM: 10528 kB physical used for 22588 kB in swap (65532 kB total swap)
      KSM: 13676 kB saved from shared 2108 kB
           73356 kB unshared; 122444 kB volatile
   Tuning: 48 (large 256), oom 40960 kB, restore limit 13653 kB (low-ram)</span>


查看某一个apk的内存使用信息,可以:dumpsys meminfo com.example.helloworld


其他的用法:dumpsys [options]

-meminfo:显示内存的信息

-cpuinfo:显示cpu的信息

-activity 显示所有的activities的信息





   
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值