android查看每个app的内存占用情况

adb shell dumpsys meminfo

会得到如下信息:

Currently running services:
  meminfo
-------------------------------------------------------------------------------
DUMP OF SERVICE meminfo:
Applications Memory Usage (kB):
Uptime: 5712383 Realtime: 5712383


** MEMINFO in pid 100 [android.process.acore] **
                    native   dalvik    other    total
            size:    10180     3591      N/A    13771
       allocated:     8590     2852      N/A    11442
            free:      297      739      N/A     1036
           (Pss):     2821     2360     4880    10061
  (shared dirty):     2768     4768     3936    11472
    (priv dirty):     2588     1172     2996     6756
 
 Objects
           Views:       40        ViewRoots:        1
     AppContexts:        9       Activities:        1
          Assets:        5    AssetManagers:        5
   Local Binders:       24    Proxy Binders:       17
Death Recipients:        1
 OpenSSL Sockets:        0
 
 SQL
            heap:      586          dbFiles:        0
       numPagers:        2   inactivePageKB:       45
    activePageKB:        0


** MEMINFO in pid 125 [com.android.settings] **
                    native   dalvik    other    total
            size:     4812     3203      N/A     8015
       allocated:     4733     2519      N/A     7252
            free:       78      684      N/A      762
           (Pss):      816     1421      732     2969
  (shared dirty):     2936     4900     1368     9204
    (priv dirty):      560      484      492     1536
 
 Objects
           Views:        0        ViewRoots:        0
     AppContexts:        1       Activities:        0
          Assets:        2    AssetManagers:        2
   Local Binders:        2    Proxy Binders:       16
Death Recipients:        1
 OpenSSL Sockets:        0
 
 SQL
            heap:        0          dbFiles:        0
       numPagers:        0   inactivePageKB:        0
    activePageKB:        0


** MEMINFO in pid 1768 [com.xinmei365.wallpaper] **
                    native   dalvik    other    total
            size:    20836     8391      N/A    29227
       allocated:    18370     5639      N/A    24009
            free:      437     2752      N/A     3189
           (Pss):     5422     8735    15611    29768
  (shared dirty):     2600     4508      924     8032
    (priv dirty):     5204     5056    11412    21672
 
 Objects
           Views:      367        ViewRoots:        1
     AppContexts:        4       Activities:        3
          Assets:        2    AssetManagers:        2
   Local Binders:       37    Proxy Binders:       23
Death Recipients:        1
 OpenSSL Sockets:        0
 
 SQL
            heap:       39          dbFiles:        0
       numPagers:        2   inactivePageKB:        9
    activePageKB:        0


** MEMINFO in pid 217 [com.svox.pico] **
                    native   dalvik    other    total
            size:     4764     3203      N/A     7967
       allocated:     4659     2426      N/A     7085
            free:       92      777      N/A      869
           (Pss):      698      961      682     2341
  (shared dirty):     3024     4932     1444     9400
    (priv dirty):      412      316      412     1140
 
 Objects
           Views:        0        ViewRoots:        0
     AppContexts:        1       Activities:        0
          Assets:        2    AssetManagers:        2
   Local Binders:        1    Proxy Binders:        5
Death Recipients:        0
 OpenSSL Sockets:        0
 
 SQL
            heap:        0          dbFiles:        0
       numPagers:        0   inactivePageKB:        0
    activePageKB:        0


** MEMINFO in pid 142 [android.process.media] **
                    native   dalvik    other    total
            size:     5792     3271      N/A     9063
       allocated:     4931     2513      N/A     7444
            free:       52      758      N/A      810
           (Pss):     1010     1493     1097     3600
  (shared dirty):     2908     4852     1164     8924
    (priv dirty):      760      684      724     2168
 
 Objects
           Views:        0        ViewRoots:        0
     AppContexts:        4       Activities:        0
          Assets:        4    AssetManagers:        4
   Local Binders:        7    Proxy Binders:        9
Death Recipients:        0
 OpenSSL Sockets:        0
 
 SQL
            heap:      155          dbFiles:        0
       numPagers:        3   inactivePageKB:       59
    activePageKB:        0


** MEMINFO in pid 184 [com.android.email] **
                    native   dalvik    other    total
            size:     4888     3203      N/A     8091
       allocated:     4876     2666      N/A     7542
            free:       11      537      N/A      548
           (Pss):      881     1221      833     2935
  (shared dirty):     2956     4952     1308     9216
    (priv dirty):      620      544      560     1724
 
 Objects
           Views:        0        ViewRoots:        0
     AppContexts:        2       Activities:        0
          Assets:        2    AssetManagers:        2
   Local Binders:        4    Proxy Binders:        8
Death Recipients:        0
 OpenSSL Sockets:        0
 
 SQL
            heap:       56          dbFiles:        0
       numPagers:        3   inactivePageKB:       13
    activePageKB:        0


** MEMINFO in pid 133 [com.android.alarmclock] **
                    native   dalvik    other    total
            size:     4764     3203      N/A     7967
       allocated:     4723     2575      N/A     7298
            free:       28      628      N/A      656
           (Pss):      726     1066      837     2629
  (shared dirty):     2980     4976     1296     9252
    (priv dirty):      460      392      564     1416
 
 Objects
           Views:        0        ViewRoots:        0
     AppContexts:        1       Activities:        0
          Assets:        2    AssetManagers:        2
   Local Binders:        2    Proxy Binders:       10
Death Recipients:        1
 OpenSSL Sockets:        0
 
 SQL
            heap:       14          dbFiles:        0
       numPagers:        1   inactivePageKB:        3
    activePageKB:        0


** MEMINFO in pid 161 [com.android.mms] **
                    native   dalvik    other    total
            size:     4808     3203      N/A     8011
       allocated:     4765     2645      N/A     7410
            free:       42      558      N/A      600
           (Pss):      802     1195      849     2846
  (shared dirty):     2952     4948     1268     9168
    (priv dirty):      540      512      624     1676
 
 Objects
           Views:        0        ViewRoots:        0
     AppContexts:        2       Activities:        0
          Assets:        2    AssetManagers:        2
   Local Binders:        2    Proxy Binders:       27
Death Recipients:        0
 OpenSSL Sockets:        0
 
 SQL
            heap:        0          dbFiles:        0
       numPagers:        0   inactivePageKB:        0
    activePageKB:        0


** MEMINFO in pid 52 [system] **
                    native   dalvik    other    total
            size:    13476     6791      N/A    20267
       allocated:     7935     4737      N/A    12672
            free:      464     2054      N/A     2518
           (Pss):     2760     6282     7747    16789
  (shared dirty):     2716     4564      952     8232
    (priv dirty):     2528     4308     4988    11824
 
 Objects
           Views:      127        ViewRoots:        6
     AppContexts:       10       Activities:        0
          Assets:        6    AssetManagers:        6
   Local Binders:       74    Proxy Binders:      114
Death Recipients:       22
 OpenSSL Sockets:        0
 
 SQL
            heap:       64          dbFiles:        0
       numPagers:        2   inactivePageKB:       21
    activePageKB:        0


** MEMINFO in pid 93 [com.android.phone] **
                    native   dalvik    other    total
            size:     5152     3847      N/A     8999
       allocated:     5073     3137      N/A     8210
            free:       78      710      N/A      788
           (Pss):     1199     2160     1109     4468
  (shared dirty):     2888     4840     1140     8868
    (priv dirty):      952     1336      860     3148
 
 Objects
           Views:        0        ViewRoots:        0
     AppContexts:        5       Activities:        0
          Assets:        3    AssetManagers:        3
   Local Binders:       31    Proxy Binders:       68
Death Recipients:        3
 OpenSSL Sockets:        0
 
 SQL
            heap:      181          dbFiles:        0
       numPagers:        2   inactivePageKB:       25
    activePageKB:        0


** MEMINFO in pid 92 [com.android.inputmethod.pinyin] **
                    native   dalvik    other    total
            size:     5860     3203      N/A     9063
       allocated:     5822     2627      N/A     8449
            free:       37      576      N/A      613
           (Pss):      946     1256     1743     3945
  (shared dirty):     2944     4932     1300     9176
    (priv dirty):      684      508     1480     2672
 
 Objects
           Views:       12        ViewRoots:        0
     AppContexts:        3       Activities:        0
          Assets:        2    AssetManagers:        2
   Local Binders:        6    Proxy Binders:       90
Death Recipients:        1
 OpenSSL Sockets:        0
 
 SQL
            heap:        0          dbFiles:        0
       numPagers:        0   inactivePageKB:        0
    activePageKB:        0


如果手机安装的app比较多的话,打印的信息会很多,可以使用

adb shell dumpsys meminfo com.***(包名)或者

adb shell dumpsys meminfo 1234(pid)

例如:

adb shell dumpsys meminfo com.xinmei365.wallpaper
Currently running services:
  meminfo
-------------------------------------------------------------------------------
DUMP OF SERVICE meminfo:
Applications Memory Usage (kB):
Uptime: 7845348 Realtime: 7845348


** MEMINFO in pid 1882 [com.xinmei365.wallpaper] **
                    native   dalvik    other    total
            size:    23884     8263      N/A    32147
       allocated:    23485     5486      N/A    28971
            free:      397     2777      N/A     3174
           (Pss):     8374     8231    18460    35065
  (shared dirty):     2604     4516     2432     9552
    (priv dirty):     8156     5228    14068    27452
 
 Objects
           Views:      437        ViewRoots:        2
     AppContexts:        4       Activities:        3
          Assets:        2    AssetManagers:        2
   Local Binders:       39    Proxy Binders:       23
Death Recipients:        1
 OpenSSL Sockets:        0
 
 SQL
            heap:       41          dbFiles:        0
       numPagers:        2   inactivePageKB:       10
    activePageKB:        0

这就是应用的内存使用情况,分析OOM很有帮助的。

更多相关文章

  1. android 复制信息内容到剪切板 (2011-12-05 09:31:11)转载▼
  2. Android有效解决加载大图片时内存溢出的问题
  3. 利用 Android Keystore 系统 加密存储和解密敏感信息
  4. Android 在界面中显示以及输入文本信息 TextView和EditText
  5. Android版本信息汇总
  6. android单元测试时,异常情况解决记录
  7. Android如何查看应用签名信息--微信平台开发应用的签名
  8. 增加Android可用内存

随机推荐

  1. Java XML - 具有相同名称的嵌套元素
  2. 算法竞赛入门经典(分数化小数)
  3. 如何在Hibernate中使用外键?
  4. 第十一章:性能和可伸缩性——Java并发编程
  5. 在servlet中的init方法得到了对数据库操
  6. 轻量级javaEE SSH 01: 概述 环境与工具篇
  7. java时间转换,long , string和date和时间
  8. Java中PreparedStatement与Statement区别
  9. Java中的观察者模式
  10. Java连接Oracle数据库简单实例