Преглед на файлове

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.
Christoph Hohmann преди 11 години
родител
ревизия
3e74e96649
променени са 1 файла, в които са добавени 3 реда и са изтрити 2 реда
  1. 3 2
      libobs/obs-nix.c

+ 3 - 2
libobs/obs-nix.c

@@ -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)