summaryrefslogtreecommitdiffstats
path: root/llvm/lib/System/Unix/Process.cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2004-12-20 16:33:37 +0000
committerReid Spencer <rspencer@reidspencer.com>2004-12-20 16:33:37 +0000
commit8005e66f0a0b5cbc0417afbbbced13d4fad4112e (patch)
tree61b0ef937566ab9485cc44ccc2f4a78d3134931b /llvm/lib/System/Unix/Process.cpp
parent1cf74cee2105efefc043ddb80051fe9f8db4b82f (diff)
downloadbcm5719-llvm-8005e66f0a0b5cbc0417afbbbced13d4fad4112e.tar.gz
bcm5719-llvm-8005e66f0a0b5cbc0417afbbbced13d4fad4112e.zip
Provide a getrusage based implementation of GetTotalMemoryUsage and use
the ru_maxrss field as an approximation. llvm-svn: 19072
Diffstat (limited to 'llvm/lib/System/Unix/Process.cpp')
-rw-r--r--llvm/lib/System/Unix/Process.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/System/Unix/Process.cpp b/llvm/lib/System/Unix/Process.cpp
index c9507cb4e7b..eef6535ee90 100644
--- a/llvm/lib/System/Unix/Process.cpp
+++ b/llvm/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;
OpenPOWER on IntegriCloud