From b9376dde1461ba01eb357cbf71da012aa4b1bbd0 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Mon, 20 Dec 2004 16:33:37 +0000 Subject: [PATCH] Provide a getrusage based implementation of GetTotalMemoryUsage and use the ru_maxrss field as an approximation. llvm-svn: 19072 --- lib/System/Unix/Process.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/System/Unix/Process.cpp b/lib/System/Unix/Process.cpp index c9507cb4e7b..eef6535ee90 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;