From a73dc6dbf46624109fdcc934d3925ec967d1ff3d Mon Sep 17 00:00:00 2001 From: Peter Boyle Date: Fri, 28 Jun 2024 16:05:17 +0000 Subject: [PATCH] Display linux heap info --- Grid/allocator/MemoryManager.cc | 23 ++++++++++++++++++++++- Grid/allocator/MemoryManager.h | 1 + 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Grid/allocator/MemoryManager.cc b/Grid/allocator/MemoryManager.cc index a9e5c9b4..c71f3512 100644 --- a/Grid/allocator/MemoryManager.cc +++ b/Grid/allocator/MemoryManager.cc @@ -16,6 +16,27 @@ NAMESPACE_BEGIN(Grid); uint64_t total_shared; uint64_t total_device; uint64_t total_host;; + +void MemoryManager::DisplayMallinfo(void) +{ +#ifdef __linux__ + struct mallinfo mi; + + mi = mallinfo(); + + printf("Total non-mmapped bytes (arena): %d\n", mi.arena); + printf("# of free chunks (ordblks): %d\n", mi.ordblks); + printf("# of free fastbin blocks (smblks): %d\n", mi.smblks); + printf("# of mapped regions (hblks): %d\n", mi.hblks); + printf("Bytes in mapped regions (hblkhd): %d\n", mi.hblkhd); + printf("Max. total allocated space (usmblks): %d\n", mi.usmblks); + printf("Free bytes held in fastbins (fsmblks): %d\n", mi.fsmblks); + printf("Total allocated space (uordblks): %d\n", mi.uordblks); + printf("Total free space (fordblks): %d\n", mi.fordblks); + printf("Topmost releasable block (keepcost): %d\n", mi.keepcost); +#endif +} + void MemoryManager::PrintBytes(void) { std::cout << " MemoryManager : ------------------------------------ "<