about summary refs log tree commit diff homepage
path: root/lib/Support/MemoryUsage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Support/MemoryUsage.cpp')
-rw-r--r--lib/Support/MemoryUsage.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/Support/MemoryUsage.cpp b/lib/Support/MemoryUsage.cpp
index 1bdff819..94cee79e 100644
--- a/lib/Support/MemoryUsage.cpp
+++ b/lib/Support/MemoryUsage.cpp
@@ -13,7 +13,13 @@
 using namespace klee;
 
 size_t util::GetTotalMemoryUsage() {
-  // This is linux platform specific
   struct mallinfo mi = ::mallinfo();
+  // The malloc implementation in glibc (pmalloc2)
+  // does not include mmap()'ed memory in mi.uordblks
+  // but other implementations (e.g. tcmalloc) do.
+#if defined(__GLIBC__)
   return mi.uordblks + mi.hblkhd;
+#else
+  return mi.uordblks;
+#endif
 }