Unverified Commit af217532 authored by Yossi Gottlieb's avatar Yossi Gottlieb Committed by GitHub
Browse files

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.
parent 9b4edfdf
...@@ -414,9 +414,9 @@ size_t zmalloc_get_rss(void) { ...@@ -414,9 +414,9 @@ size_t zmalloc_get_rss(void) {
if (sysctl(mib, 4, &info, &infolen, NULL, 0) == 0) if (sysctl(mib, 4, &info, &infolen, NULL, 0) == 0)
#if defined(__FreeBSD__) #if defined(__FreeBSD__)
return (size_t)info.ki_rssize; return (size_t)info.ki_rssize * getpagesize();
#else #else
return (size_t)info.kp_vm_rssize; return (size_t)info.kp_vm_rssize * getpagesize();
#endif #endif
return 0L; return 0L;
...@@ -436,7 +436,7 @@ size_t zmalloc_get_rss(void) { ...@@ -436,7 +436,7 @@ size_t zmalloc_get_rss(void) {
mib[4] = sizeof(info); mib[4] = sizeof(info);
mib[5] = 1; mib[5] = 1;
if (sysctl(mib, 4, &info, &infolen, NULL, 0) == 0) 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; return 0L;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment