vmmap命令是否有任何API [英] Is there any API for the command vmmap

查看:121
本文介绍了vmmap命令是否有任何API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在命令行中,我可以使用vmmap -v -purge 50554查找进程50554的内存信息,并获得如下输出:

In the command line, i can use vmmap -v -purge 50554 to find the memory information of the process 50554, and get the output like below:

                                  VIRTUAL RESIDENT    DIRTY  SWAPPED VOLATILE   NONVOL    EMPTY   REGION 
REGION TYPE                          SIZE     SIZE     SIZE     SIZE     SIZE     SIZE     SIZE    COUNT (non-coalesced) 
===========                       ======= ========    =====  ======= ========   ======    =====  ======= 
Accelerate.framework                 256K     256K     256K       0K       0K     256K       0K        3 
Activity Tracing                    2048K      40K      40K       0K       0K       0K       0K        2 

......
                                          VIRTUAL   RESIDENT      DIRTY    SWAPPED ALLOCATION      BYTES          REGION
MALLOC ZONE                                  SIZE       SIZE       SIZE       SIZE      COUNT  ALLOCATED  % FULL   COUNT
===========                               =======  =========  =========  =========  =========  =========  ======  ======
DefaultMallocZone_0x10453d000              532.5M     524.4M     476.8M         0K    3203739     424.3M     79%     829
DefaultPurgeableMallocZone_0x117c92000      14.2M      13.7M      13.7M         0K          3      14.2M     99%       4
WebKit Malloc_0x7fff7c65ecb8                12.0M      8928K      8756K         0K          3      12.0M    100%       3
QuartzCore_0x7fc9519bc000                   1516K      1516K      1516K         0K      27313      1390K     91%     207
unnamed_zone_0x120a0a000                    1024K        12K        12K         0K          4        224      0%       2
x-alloc_0x7fc95189ec00                        12K        12K        12K         0K         48       1696     13%       1
x-alloc_0x7fc951047800                         8K         8K         8K         0K          4        448      5%       1
GFXMallocZone_0x10598d000                      0K         0K         0K         0K          0         0K               0
===========                               =======  =========  =========  =========  =========  =========  ======  ======
TOTAL                                      561.1M     548.3M     500.5M         0K    3231114     451.8M     80%    1047

但是我可以调用实现相同功能的任何API吗?

But is there any API that i can call the implement the same function?

推荐答案

您的问题的答案有些复杂,但是可以在mach_vm_region_info()的内核源代码中找到:

The answer to your question is somewhat complex, but can be found in the kernel source code for mach_vm_region_info(): https://opensource.apple.com/source/xnu/xnu-201/osfmk/vm/vm_debug.c

此代码(除其他事项外)贯穿VM映射表,并构建结构的链接列表,其中包含vmmap(1)命令显示的所有信息.

This code (among other things) runs through the VM map table and builds a linked list of structures which contain all of the info displayed by the vmmap(1) command.

这篇关于vmmap命令是否有任何API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆