Implement OS_DumpMemoryCounters for Linux

This commit is contained in:
LoopDawg 2017-11-13 15:54:12 -07:00 committed by John Kessenich
parent 74bde98778
commit fc3e86472a

View File

@ -43,6 +43,9 @@
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
#include <stdint.h> #include <stdint.h>
#include <cstdio>
#include <sys/time.h>
#include <sys/resource.h>
namespace glslang { namespace glslang {
@ -184,8 +187,18 @@ void ReleaseGlobalLock()
pthread_mutex_unlock(&gMutex); pthread_mutex_unlock(&gMutex);
} }
// #define DUMP_COUNTERS
void OS_DumpMemoryCounters() 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 } // end namespace glslang