title: How to get the memory usage of a process in Mac OS (and in iOS)?
body: <p>In Linux, the kernel exposes various per-process memory counters through /proc/[pid]/statm including</p>
  
  <ul>
  <li>total program size</li>
  <li>resident set size</li>
  <li>shared pages</li>
  <li>text (code)</li>
  <li>data/stack</li>
  <li>library</li>
  <li>dirty pages</li>
  </ul>
  
  <p>What is the equivalent of such thing in Mac OS (and iOS)? I am aware of the sysctl interface, but it does not appear to provide the equivalent information.</p>
  
  <p>I have looked at the "top" output (invoked by non-root user) on Mac OS and it contains things like</p>
  
  <ul>
  <li>RPRVT - amount of resident memory consumed by our heap allocations</li>
  <li>RSHRD - amount of resident shared memory (shared libraries)</li>
  <li>RSIZE - ~equals RPRVT + RSHRD</li>
  <li>VSIZE - the total amount of memory consumed by the process (resident and paged mem combined)</li>
  </ul>
  
  <p>I wonder where such information is retrieved. Are there any additional counters (similar to the Linux ones) that are not displayed by top. </p>
  
  <p>What about iOS?</p>
  
  <p>EDIT: note that I'm looking for the per-process memory usage counter (not global system ones)</p>
  
  <p>Thanks!</p>