about summary refs log tree commit diff homepage
path: root/lib/Support
diff options
context:
space:
mode:
authorFrank Busse <bb0xfb@gmail.com>2022-03-18 09:06:48 +0000
committerMartinNowack <2443641+MartinNowack@users.noreply.github.com>2022-04-25 18:13:56 +0100
commit33bac31837938c0fdc143022ae8498beb57510a8 (patch)
treed8018c568ae1d44599504500ed86b624468582c8 /lib/Support
parentee94e78a5bde3b491282db7acf1620c224119459 (diff)
downloadklee-33bac31837938c0fdc143022ae8498beb57510a8.tar.gz
use mallinfo2 if available
Diffstat (limited to 'lib/Support')
-rw-r--r--lib/Support/MemoryUsage.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Support/MemoryUsage.cpp b/lib/Support/MemoryUsage.cpp
index 6e9f9424..5878939e 100644
--- a/lib/Support/MemoryUsage.cpp
+++ b/lib/Support/MemoryUsage.cpp
@@ -16,7 +16,7 @@
 #include "gperftools/malloc_extension.h"
 #endif
 
-#ifdef HAVE_MALLINFO
+#if defined(HAVE_MALLINFO) || defined(HAVE_MALLINFO2)
 #include <malloc.h>
 #endif
 #ifdef HAVE_MALLOC_ZONE_STATISTICS
@@ -96,6 +96,10 @@ size_t util::GetTotalMallocUsage() {
   MallocExtension::instance()->GetNumericProperty(
       "generic.current_allocated_bytes", &value);
   return value;
+#elif defined(HAVE_MALLINFO2)
+  // niy in tcmalloc
+  struct mallinfo2 mi = ::mallinfo2();
+  return mi.uordblks + mi.hblkhd;
 #elif defined(HAVE_MALLINFO)
   struct mallinfo mi = ::mallinfo();
   // The malloc implementation in glibc (pmalloc2)