Android MemInfo 各项的意义(转)

可以使用adb shell dumpsys meminfo -a <process id>/<process name>来查看一个进程的memory。

Naitve Heap Size: 从mallinfo usmblks获得,代表最大总共分配空间

Native Heap Alloc: 从mallinfo uorblks获得,总共分配空间

Native Heap Free: 从mallinfo fordblks获得,代表总共剩余空间

Native Heap Size 约等于Native Heap Alloc + Native Heap Free

mallinfo是一个C库, mallinfo 函数提供了各种各样的通过C的malloc()函数分配的内存的统计信息。

Dalvik Heap Size:从Runtime totalMemory()获得,Dalvik Heap总共的内存大小。

Dalvik Heap Alloc: Runtime totalMemory()-freeMemory() ,Dalvik Heap分配的内存大小。

Dalvik Heap Free:从Runtime freeMemory()获得,Dalvik Heap剩余的内存大小。

Dalvik Heap Size 约等于Dalvik  Heap Alloc + Dalvik  Heap Free

OtherPss, include Cursor,Ashmem, Other Dev, .so mmap, .jar mmap, .apk mmap, .ttf mmap, .dex mmap, Other mmap, Unkown统计信息都可以在process的smap文件看到。

Objects and SQL 信息都是从Android Debug信息中获得。

其他类型               smap 路径名称          描述

Cursor                  /dev/ashmem/Cursor  Cursor消耗的内存(KB)

Ashmem               /dev/ashmem            匿名共享内存用来提供共享内存通过分配一个多个进程

可以共享的带名称的内存块

Other dev             /dev/                        内部driver占用的在 “Other dev”

.so mmap             .so                            C 库代码占用的内存

.jar mmap            .jar                           Java 文件代码占用的内存

.apk mmap           .apk                           apk代码占用的内存

.ttf mmap              .ttf                           ttf 文件代码占用的内存

.dex mmap             .dex                         Dex 文件代码占用的内存

Other mmap                                          其他文件占用的内存

But as to what the difference is between "Pss", "PrivateDirty", and "SharedDirty"... well now the fun begins.

A lot of memory in Android (and Linux systems in general) is actually shared across multiple processes. So how much memory a processes uses is really not clear. Add on top of that paging out to disk (let alone swap which we don't use on Android) and it is even less clear.

Thus if you were to take all of the physical RAM actually mapped in to each process, and add up all of the processes, you would probably end up with a number much greater than the actual total RAM.

The Pss number is a metric the kernel computes that takes into account memory sharing -- basically each page of RAM in a process is scaled by a ratio of the number of other processes also using that page. This way you can (in theory) add up the pss across all processes to see the total RAM they are using, and compare pss between processes to get a rough idea of their relative weight.

The other interesting metric here is PrivateDirty, which is basically the amount of RAM inside the process that can not be paged to disk (it is not backed by the same data on disk), and is not shared with any other processes. Another way to look at this is the RAM that will become available to the system when that process goes away (and probably quickly subsumed into caches and other uses of it).

That is pretty much the SDK APIs for this. However there is more you can do as a developer with your device.

Using adb, there is a lot of information you can get about the memory use of a running system. A common one is the command "adb shell dumpsys meminfo" which will spit out a bunch of information about the memory use of each Java process, containing the above info as well as a variety of other things. You can also tack on the name or pid of a single process to see, for example "adb shell dumpsys meminfo system" give me the system process:

** MEMINFO in pid 890 [system] **native   dalvik    other    totalsize:    10940     7047      N/A    17987allocated:     8943     5516      N/A    14459free:      336     1531      N/A     1867(Pss):     4585     9282    11916    25783(shared dirty):     2184     3596      916     6696(priv dirty):     4504     5956     7456    17916ObjectsViews:      149        ViewRoots:        4AppContexts:       13       Activities:        0Assets:        4    AssetManagers:        4Local Binders:      141    Proxy Binders:      158
Death Recipients:       49OpenSSL Sockets:        0SQLheap:      205          dbFiles:        0numPagers:        0   inactivePageKB:        0activePageKB:        0

The top section is the main one, where "size" is the total size in address space of a particular heap, "allocated" is the kb of actual allocations that heap thinks it has, "free" is the remaining kb free the heap has for additional allocations, and "pss" and "priv dirty" are the same as discussed before specific to pages associated with each of the heaps.

If you just want to look at memory usage across all processes, you can use the command "adb shell procrank". Output of this on the same system looks like:

  PID      Vss      Rss      Pss      Uss  cmdline890   84456K   48668K   25850K   21284K  system_server1231   50748K   39088K   17587K   13792K  com.android.launcher2947   34488K   28528K   10834K    9308K  com.android.wallpaper987   26964K   26956K    8751K    7308K  com.google.process.gapps954   24300K   24296K    6249K    4824K  com.android.phone948   23020K   23016K    5864K    4748K  com.android.inputmethod.latin888   25728K   25724K    5774K    3668K  zygote977   24100K   24096K    5667K    4340K  android.process.acore
...59     336K     332K      99K      92K  /system/bin/installd60     396K     392K      93K      84K  /system/bin/keystore51     280K     276K      74K      68K  /system/bin/servicemanager54     256K     252K      69K      64K  /system/bin/debuggerd

Here the Vss and Rss columns are basically noise (these are the straight-forward address space and RAM usage of a process, where if you add up the RAM usage across processes you get an ridiculously large number).

Pss is as we've seen before, and Uss is Priv Dirty.

Interesting thing to note here: Pss and Uss are slightly (or more than slightly) different than what we saw in meminfo. Why is that? Well procrank uses a different kernel mechanism to collect its data than meminfo does, and they give slightly different results. Why is that? Honestly I haven't a clue. I believe procrank may be the more accurate one... but really, this just leave the point: "take any memory info you get with a grain of salt; often a very large grain."

Finally there is the command "adb shell cat /proc/meminfo" that gives a summary of the overall memory usage of the system. There is a lot of data here, only the first few numbers worth discussing (and the remaining ones understood by few people, and my questions of those few people about them often resulting in conflicting explanations):

MemTotal:         395144 kB
MemFree:          184936 kB
Buffers:             880 kB
Cached:            84104 kB
SwapCached:            0 kB

MemTotal is the total amount of memory available to the kernel and user space (often less than the actual physical RAM of the device, since some of that RAM is needed for the radio, DMA buffers, etc).

MemFree is the amount of RAM that is not being used at all. The number you see here is very high; typically on an Android system this would be only a few MB, since we try to use available memory to keep processes running

Cached is the RAM being used for filesystem caches and other such things. Typical systems will need to have 20MB or so for this to avoid getting into bad paging states; the Android out of memory killer is tuned for a particular system to make sure that background processes are killed before the cached RAM is consumed too much by them to result in such paging.

Android MemInfo 各项的意义(转)相关推荐

  1. 任务管理器-性能中各项的意义

    任务管理器-性能中各项的意义 总数:句柄数,线程数,进程数 物理内存(k):总数,可用数,系统缓存, 内存使用:总数,限制,峰值, 核心内存:总数,分页数,未分页, PF使用 都是什么意思? 一:总数 ...

  2. android meminfo,Android中dumpsys meminfo与/proc/meminfo获取空闲内存不一致的问题

    一.需求 获取当前系统中应用可用的空闲内存. 二.遇到的问题 方法一:dumpsys meminfo Total RAM: 3,498,412K (status normal) Free RAM: 1 ...

  3. android自定义插值器_自定义缓动插值器,可在Android中实现有意义的动作

    android自定义插值器 Interpolators are very useful to model movement for your UI elements. In this article, ...

  4. android 刷机的意义,关于刷android手机

    总结一下关于刷Android第三方ROM的新手级经验! 刷机分几种? 我们所说刷机,就是在android手机中刷入第三方的ROM,我觉得这个过程应该分三种!(首先说明: 我是小白,在此只是记录下自己刷 ...

  5. Android meminfo

    经典博文:Android内存分析命令 Android中有一些内存信息查看工具: dumpsys meminfo cat /proc/meminfo 今天就说说这两个之间的关系.dumpsys memi ...

  6. android中sp的意义_两分钟理解Android中SP与DP的区别

    从一开始写Android程序,就被告知这些常识 长度宽度的数值要使用dp作为单位放入dimens.xml文件中 字体大小的数值要使用sp作为单位,也放入dimens.xml文件中 然后,就没有然后了, ...

  7. android中sp的意义_简单谈谈Android中SP与DP的区别

    从一开始写android程序,就被告知这些常识 一.dp(或者dip device independent pixels) 一种基于屏幕密度的抽象单位.在每英寸160点的显示器上,1dp=1px.不同 ...

  8. ImageView.ScaleType /android:scaleType值的意义区别

    CENTER /center按图片的原来size居中显示,当图片长/宽超过View的长/宽,则截取图片的居中部分显示 CENTER_CROP / centerCrop 按比例扩大图片的size居中显示 ...

  9. 手机开发者选项各项参数意义

    停用HW叠加层,所有应用将共享视频内存,将不会经常检查碰撞与裁剪以显示一个合适的图像,将会耗费大量处理能力.而HW叠加层允许应用有单独的视频内存,性能自然要好些. HW在这里的意思是硬件加速,叠加层的 ...

最新文章

  1. 基于Java的RDMA高性能通信库(一):IBM jVerbs库
  2. 《POSIX多线程程序设计》读书笔记
  3. 程序物语(六):探寻你的与众不同之处
  4. 基于Netty+Zookeeper实现Dubbo
  5. object address data read debug
  6. 居家洁士扫地机器人_掌握核心技术扫地机器人品牌推荐,由利和石头扫地机器人哪个牌子好?...
  7. python 输入参数有误_Python OpenCV错误:输入参数的大小不匹配
  8. 高通手机调试烧录—QFIL工具
  9. python实现协同过滤推荐算法完整代码示例
  10. 双目测距Python-OpenCV代码及详细解释
  11. 11_超级鹰学习及应用
  12. 自适应函数符和函数适配器(Adaptable Functors and Function Adapters)
  13. 一周信创舆情观察(5.6~5.9)
  14. 转回到Edison上开发
  15. Div中嵌套一个div,怎么是里面的div居中?
  16. Maximo 容器化改造试验
  17. Windows系统复制文件到虚拟机Linux环境的解决
  18. 骑行318、 2016.7.18
  19. Win32 Disk Imager Error 5: Access is Denied 解决方案
  20. 计算机病毒实训,2021计算机病毒实验报告

热门文章

  1. 计算机主板的概念,华硕新型概念主机大爆料:内置未来主板
  2. windows linux双系统_还在安装双系统? 试试 Windows 和 Linux 合体
  3. python3调用adb命令_Python操作adb命令
  4. Cortex-M3的存储器系统
  5. 【AD】PCB设计知识整理(持续更新)
  6. Keil综合(01)一些常见文件类型的作用和功能说明
  7. linux多线程学习(七)——实现“生产者和消费者”
  8. 【数电】(二) 基本逻辑运算与逻辑门电路
  9. 计算机编程竞赛怎么入门,acm编程比赛入门题目集..pdf
  10. ai怎么渐变颜色_你根本想不到AI的混合工具有多神奇!