about summary refs log tree commit diff homepage
path: root/lib/Support
diff options
context:
space:
mode:
authorMartin Nowack <martin@se.inf.tu-dresden.de>2016-02-23 15:29:58 +0100
committerMartin Nowack <martin@se.inf.tu-dresden.de>2016-02-27 10:21:19 +0100
commitc813f1464ce8ad98d45a6a132499247251e15d96 (patch)
tree2f25d008108cdb428eeb919b654b87283f1ff0d6 /lib/Support
parent66f53aac10962db150aec07b96f3b0a756eef28b (diff)
downloadklee-c813f1464ce8ad98d45a6a132499247251e15d96.tar.gz
Add support for tcmalloc
Beside improving performance of KLEE,
tcmalloc allows to track used memory correctly.

If available, tcmalloc is automatically used during compile time.

This can be forced to be:
 - disabled using --without-tcmalloc
 - enabled using --with-tcmalloc
In the second case, configure will fail if tcmalloc
is not found or usable.

Both versions of tcmalloc a minimal and normal version.
Diffstat (limited to 'lib/Support')
-rw-r--r--lib/Support/MemoryUsage.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/Support/MemoryUsage.cpp b/lib/Support/MemoryUsage.cpp
index 32a7eb3b..a9f4026d 100644
--- a/lib/Support/MemoryUsage.cpp
+++ b/lib/Support/MemoryUsage.cpp
@@ -11,6 +11,10 @@
 
 #include "klee/Config/config.h"
 
+#ifdef HAVE_GPERFTOOLS_MALLOC_EXTENSION_H
+#include "gperftools/malloc_extension.h"
+#endif
+
 #ifdef HAVE_MALLINFO
 #include <malloc.h>
 #endif
@@ -21,7 +25,12 @@
 using namespace klee;
 
 size_t util::GetTotalMallocUsage() {
-#ifdef HAVE_MALLINFO
+#ifdef HAVE_GPERFTOOLS_MALLOC_EXTENSION_H
+  uint64_t value;
+  MallocExtension::instance()->GetNumericProperty(
+      "generic.current_allocated_bytes", &value);
+  return value;
+#elif HAVE_MALLINFO
   struct mallinfo mi = ::mallinfo();
   // The malloc implementation in glibc (pmalloc2)
   // does not include mmap()'ed memory in mi.uordblks