From c8bbb6a75d4ad7efe8f438ca7c82ed31a734049a Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Sat, 4 Aug 2007 19:02:27 +0000 Subject: [PATCH] use vmstat util for freebsd mem.free --- src/os/darwin/darwin_sigar.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/os/darwin/darwin_sigar.c b/src/os/darwin/darwin_sigar.c index ac5f789c..fb78cd09 100644 --- a/src/os/darwin/darwin_sigar.c +++ b/src/os/darwin/darwin_sigar.c @@ -340,15 +340,15 @@ static int sigar_vmstat(sigar_t *sigar, struct vmmeter *vmstat) int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem) { #ifdef DARWIN - int status; vm_statistics_data_t vmstat; uint64_t mem_total; #else unsigned long mem_total; - int mem_free; + struct vmmeter vmstat; #endif int mib[2]; size_t len; + int status; mib[0] = CTL_HW; @@ -377,14 +377,8 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem) mem->free = vmstat.free_count * sigar->pagesize; #elif defined(__FreeBSD__) - len = sizeof(mem_free); - if (sysctlbyname("vm.stats.vm.v_free_count", - &mem_free, &len, NULL, 0) == -1) - { - mem->free = 0; /*XXX*/ - } - else { - mem->free = mem_free; + if ((status = sigar_vmstat(sigar, &vmstat)) == SIGAR_OK) { + mem->free = vmstat.v_free_count; mem->free *= sigar->pagesize; } #else