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.
This commit is contained in:
Yossi Gottlieb 2021-03-09 11:33:32 +02:00 committed by GitHub
parent 9b4edfdf08
commit af2175326c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
}