Question

When I use 'vmmap' (Or Allocations tool in Instruments), one of the lines of output is 'mapped file'. How can I get this number programmatically?

vmmap output:

REGION TYPE             [ VIRTUAL]
===========             [ =======]
ATS (font support)      [   32.9M]
CG backing stores       [  110.1M]
CG raster data          [     64K]
CG shared images        [   2284K]
Carbon                  [   3444K]
CoreGraphics            [      8K]
IOKit                   [  512.8M]
MALLOC                  [  264.7M]
Memory tag=240          [      4K]
Memory tag=242          [     12K]
Memory tag=243          [     12K]
Memory tag=249          [    192K]
OpenGL GLSL             [   3072K]
STACK GUARD             [   56.5M]
Stack                   [   57.4M]
VM_ALLOCATE             [  827.7M]
__DATA                  [   23.3M]
__DATA/__OBJC           [     12K]
__IMAGE                 [   1240K]
__IMPORT                [    732K]
__LINKEDIT              [   80.1M]
__OBJC                  [   1148K]
__OBJC/__DATA           [     12K]
__PAGEZERO              [      4K]
__TEXT                  [  232.2M]
__UNICODE               [    536K]
mapped file             [   38.9M]
shared memory           [    580K]
shared pmap             [   7440K]
Was it helpful?

Solution

"The mach system call vm_region retrieves the information used by vmmap."

From http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/vmmap.1.html.

OTHER TIPS

I didn't try to look how vmmap does it, but from what I see, looking at regions from vm_region_recurse_64 with

  • vm_region_submap_info_64.user_tag == 0,
  • not in the SHARED_REGION_BASE..SHARED_REGION_BASE+SHARED_REGION_SIZE range
  • with non-empty path from proc_regionfilename()

...should be quite close. Suggestions on the better way to do this are welcome!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top