From af2175326c87231d16c5633dd8febbc86a258540 Mon Sep 17 00:00:00 2001 From: Yossi Gottlieb Date: Tue, 9 Mar 2021 11:33:32 +0200 Subject: [PATCH] Fix memory info on FreeBSD. (#8620) The obtained process_rss was incorrect (the OS reports pages, not bytes), resulting with many other fields getting corrupted. This has been tested on FreeBSD but not other platforms. --- src/zmalloc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/zmalloc.c b/src/zmalloc.c index 1dc662e5..e212583a 100644 --- a/src/zmalloc.c +++ b/src/zmalloc.c @@ -414,9 +414,9 @@ size_t zmalloc_get_rss(void) { if (sysctl(mib, 4, &info, &infolen, NULL, 0) == 0) #if defined(__FreeBSD__) - return (size_t)info.ki_rssize; + return (size_t)info.ki_rssize * getpagesize(); #else - return (size_t)info.kp_vm_rssize; + return (size_t)info.kp_vm_rssize * getpagesize(); #endif return 0L; @@ -436,7 +436,7 @@ size_t zmalloc_get_rss(void) { mib[4] = sizeof(info); mib[5] = 1; if (sysctl(mib, 4, &info, &infolen, NULL, 0) == 0) - return (size_t)info.p_vm_rssize; + return (size_t)info.p_vm_rssize * getpagesize(); return 0L; }