在命令行中,我可以使用vmmap -v -purge 50554
查找进程50554的内存信息,并获取如下输出:
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?
答案 0 :(得分:2)
您的问题的答案有点复杂,但可以在mach_vm_region_info()的内核源代码中找到:https://opensource.apple.com/source/xnu/xnu-201/osfmk/vm/vm_debug.c
此代码(以及其他内容)在VM映射表中运行,并构建一个包含vmmap(1)命令显示的所有信息的结构链接列表。