5

I'd like to add memory profiler to my daemon which runs under macOS. In linux, i could simply check the /proc/<pid>/map for any mapped memory in the process, and look for pathname = [heap] or pathname = [stack].

Is there any alternative mac syscall/MIG/mach message for that purpose ?

I've tried to see if proc_pidinfo contain any valuable information, but unfortunately nothing related to my needs.

Notice that apple provide such tool for other remote processes called vmmap and it doesn't provide any api at all (it's merely command-line tool) and there's no public API for this demand, but perhaps there's an API to extract this information from "within" the process itself.

Andre Holzner
  • 18,333
  • 6
  • 54
  • 63
Zohar81
  • 4,554
  • 5
  • 29
  • 82

1 Answers1

3

I don't know what public APIs (if any) it uses, but the closest equivalent to Linux's /proc/$pid/maps in macOS is the vmmap utility. Running it with a PID as an argument will give you a detailed report on all regions mapped by the process, including some interesting details on memory usage within malloc zones.

  • Yes it does, but i'd like to base an in-process memory profiler so i need some API, are you familiar with any private one ? thanks – Zohar81 Oct 19 '17 at 20:58
  • This [question](https://stackoverflow.com/questions/33337740/is-there-any-api-for-the-command-vmmap) may help. – CRD Oct 20 '17 at 06:40