From fc3e86472a757255b62df236c72aac553c68e59c Mon Sep 17 00:00:00 2001 From: LoopDawg Date: Mon, 13 Nov 2017 15:54:12 -0700 Subject: [PATCH] Implement OS_DumpMemoryCounters for Linux --- glslang/OSDependent/Unix/ossource.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/glslang/OSDependent/Unix/ossource.cpp b/glslang/OSDependent/Unix/ossource.cpp index 24b77e16..f59bbceb 100644 --- a/glslang/OSDependent/Unix/ossource.cpp +++ b/glslang/OSDependent/Unix/ossource.cpp @@ -43,6 +43,9 @@ #include #include #include +#include +#include +#include namespace glslang { @@ -184,8 +187,18 @@ void ReleaseGlobalLock() pthread_mutex_unlock(&gMutex); } +// #define DUMP_COUNTERS + void OS_DumpMemoryCounters() { +#ifdef DUMP_COUNTERS + struct rusage usage; + + if (getrusage(RUSAGE_SELF, &usage) == 0) + printf("Working set size: %ld\n", usage.ru_maxrss * 1024); +#else + printf("Recompile with DUMP_COUNTERS defined to see counters.\n"); +#endif } } // end namespace glslang