From 33bac31837938c0fdc143022ae8498beb57510a8 Mon Sep 17 00:00:00 2001 From: Frank Busse Date: Fri, 18 Mar 2022 09:06:48 +0000 Subject: use mallinfo2 if available --- lib/Support/MemoryUsage.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/Support') diff --git a/lib/Support/MemoryUsage.cpp b/lib/Support/MemoryUsage.cpp index 6e9f9424..5878939e 100644 --- a/lib/Support/MemoryUsage.cpp +++ b/lib/Support/MemoryUsage.cpp @@ -16,7 +16,7 @@ #include "gperftools/malloc_extension.h" #endif -#ifdef HAVE_MALLINFO +#if defined(HAVE_MALLINFO) || defined(HAVE_MALLINFO2) #include #endif #ifdef HAVE_MALLOC_ZONE_STATISTICS @@ -96,6 +96,10 @@ size_t util::GetTotalMallocUsage() { MallocExtension::instance()->GetNumericProperty( "generic.current_allocated_bytes", &value); return value; +#elif defined(HAVE_MALLINFO2) + // niy in tcmalloc + struct mallinfo2 mi = ::mallinfo2(); + return mi.uordblks + mi.hblkhd; #elif defined(HAVE_MALLINFO) struct mallinfo mi = ::mallinfo(); // The malloc implementation in glibc (pmalloc2) -- cgit 1.4.1