about summary refs log tree commit diff homepage
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Support/MemoryUsage.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Support/MemoryUsage.cpp b/lib/Support/MemoryUsage.cpp
index 6143b127..32a7eb3b 100644
--- a/lib/Support/MemoryUsage.cpp
+++ b/lib/Support/MemoryUsage.cpp
@@ -14,6 +14,9 @@
 #ifdef HAVE_MALLINFO
 #include <malloc.h>
 #endif
+#ifdef HAVE_MALLOC_MALLOC_H
+#include <malloc/malloc.h>
+#endif
 
 using namespace klee;
 
@@ -29,6 +32,13 @@ size_t util::GetTotalMallocUsage() {
   return mi.uordblks;
 #endif
 
+#elif defined(HAVE_MALLOC_ZONE_STATISTICS) && defined(HAVE_MALLOC_MALLOC_H)
+
+  // Support memory usage on Darwin.
+  malloc_statistics_t Stats;
+  malloc_zone_statistics(malloc_default_zone(), &Stats);
+  return Stats.size_in_use;
+
 #else // HAVE_MALLINFO
 
 #warning Cannot get malloc info on this platform