Fix calculation of physical memory on linux systems

As stated in the sysinfo manpage the totalram field in the sysinfo
structure is in mem_unit sizes since Linux 2.3.23. To get the actual
memory in the system the totalram value has to be multiplied with the
mem_unit size.
This commit is contained in:
Christoph Hohmann 2014-10-04 23:30:15 +02:00 committed by jp9000
parent 2edac33c58
commit 3e74e96649

View File

@ -21,6 +21,7 @@
#include <unistd.h>
#include <sys/sysinfo.h>
#include <sys/utsname.h>
#include <inttypes.h>
#include "util/dstr.h"
#include "obs-internal.h"
@ -128,8 +129,8 @@ static void log_memory_info(void)
if (sysinfo(&info) < 0)
return;
blog(LOG_INFO, "Physical Memory: %luMB Total",
info.totalram / 1024 / 1024);
blog(LOG_INFO, "Physical Memory: %"PRIu64"MB Total",
(uint64_t)info.totalram * info.mem_unit / 1024 / 1024);
}
static void log_kernel_version(void)