diff options
Diffstat (limited to 'lib/Support')
-rw-r--r-- | lib/Support/MemoryUsage.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/Support/MemoryUsage.cpp b/lib/Support/MemoryUsage.cpp new file mode 100644 index 00000000..676ce307 --- /dev/null +++ b/lib/Support/MemoryUsage.cpp @@ -0,0 +1,25 @@ +//===-- MemoryUsage.cpp ---------------------------------------------------===// +// +// The KLEE Symbolic Virtual Machine +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "klee/Internal/System/MemoryUsage.h" +#include <malloc.h> + +using namespace klee; + +size_t util::GetTotalMallocUsage() { + 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 +} |