//===-- 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 "klee/Config/config.h" #ifdef HAVE_MALLINFO #include #endif using namespace klee; size_t util::GetTotalMallocUsage() { #ifdef HAVE_MALLINFO 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 #else // HAVE_MALLINFO #warning Cannot get malloc info on this platform return 0; #endif }