From e9b32eb62f6505fd065022cdd085ae6d8e5e0e46 Mon Sep 17 00:00:00 2001 From: Hisham Date: Sat, 13 Feb 2016 02:13:57 -0200 Subject: [PATCH] Fix memory accounting in Darwin. htop currently expects m_size and m_resident in pages (Process.c). According to the proc_info.h header, the values returned by libproc are in bytes: http://www.opensource.apple.com/source/xnu/xnu-1456.1.26/bsd/sys/proc_info.h Eventually we should change the htop crossplatform API to expect memory in bytes, but this is the smaller change that should fix it. Closes #385. --- darwin/DarwinProcess.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/darwin/DarwinProcess.c b/darwin/DarwinProcess.c index 9c460469..34d873d5 100644 --- a/darwin/DarwinProcess.c +++ b/darwin/DarwinProcess.c @@ -327,8 +327,8 @@ void DarwinProcess_setFromLibprocPidinfo(DarwinProcess *proc, DarwinProcessList proc->super.time = (pti.pti_total_system + pti.pti_total_user) / 10000000; proc->super.nlwp = pti.pti_threadnum; - proc->super.m_size = pti.pti_virtual_size / 1024; - proc->super.m_resident = pti.pti_resident_size / 1024; + proc->super.m_size = pti.pti_virtual_size / 1024 / PAGE_SIZE_KB; + proc->super.m_resident = pti.pti_resident_size / 1024 / PAGE_SIZE_KB; proc->super.majflt = pti.pti_faults; proc->super.percent_mem = (double)pti.pti_resident_size * 100.0 / (double)dpl->host_info.max_mem;