summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/System/Unix/Process.cpp4
-rw-r--r--lib/System/Unix/Process.inc4
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/System/Unix/Process.cpp b/lib/System/Unix/Process.cpp
index c9507cb4e7..eef6535ee9 100644
--- a/lib/System/Unix/Process.cpp
+++ b/lib/System/Unix/Process.cpp
@@ -74,6 +74,10 @@ Process::GetTotalMemoryUsage()
#if defined(HAVE_MALLINFO)
struct mallinfo mi = ::mallinfo();
return mi.uordblks + mi.hblkhd;
+#elif defined(HAVE_GETRUSAGE)
+ struct rusage usage;
+ ::getrusage(RUSAGE_SELF, &usage);
+ return usage.ru_maxrss;
#else
#warning Cannot get total memory size on this platform
return 0;
diff --git a/lib/System/Unix/Process.inc b/lib/System/Unix/Process.inc
index c9507cb4e7..eef6535ee9 100644
--- a/lib/System/Unix/Process.inc
+++ b/lib/System/Unix/Process.inc
@@ -74,6 +74,10 @@ Process::GetTotalMemoryUsage()
#if defined(HAVE_MALLINFO)
struct mallinfo mi = ::mallinfo();
return mi.uordblks + mi.hblkhd;
+#elif defined(HAVE_GETRUSAGE)
+ struct rusage usage;
+ ::getrusage(RUSAGE_SELF, &usage);
+ return usage.ru_maxrss;
#else
#warning Cannot get total memory size on this platform
return 0;