From 3a299c0ae9d5f1efa77ad4058148884cbe4b9611 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Thu, 13 Dec 2007 06:03:08 +0000 Subject: [PATCH] [SIGAR-37] Use libproc when possible for proc_mem --- src/os/darwin/darwin_sigar.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/os/darwin/darwin_sigar.c b/src/os/darwin/darwin_sigar.c index 9deeb9e6..111f0d13 100644 --- a/src/os/darwin/darwin_sigar.c +++ b/src/os/darwin/darwin_sigar.c @@ -818,6 +818,21 @@ int sigar_proc_mem_get(sigar_t *sigar, sigar_pid_t pid, task_basic_info_data_t info; task_events_info_data_t events; mach_msg_type_number_t count; +# ifdef DARWIN_HAS_LIBPROC_H + struct proc_taskinfo pti; + int sz = + proc_pidinfo(pid, PROC_PIDTASKINFO, 0, &pti, sizeof(pti)); + + if (sz == sizeof(pti)) { + procmem->size = pti.pti_virtual_size; + procmem->resident = pti.pti_resident_size; + procmem->page_faults = pti.pti_faults; + procmem->minor_faults = SIGAR_FIELD_NOTIMPL; + procmem->major_faults = SIGAR_FIELD_NOTIMPL; + procmem->share = SIGAR_FIELD_NOTIMPL; + return SIGAR_OK; + } +# endif status = task_for_pid(self, pid, &task);