File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5353#include < chrono>
5454#include < cstdint>
5555#include < cstdio> // [MEM] periodic logger reads /proc/self/status
56- #include < malloc.h> // [MEM] periodic malloc_trim(0) bounds glibc pool fragmentation
56+ #if defined(__GLIBC__)
57+ #include < malloc.h> // [MEM] periodic malloc_trim(0) bounds glibc pool fragmentation (glibc-only)
58+ #endif
5759#include < filesystem>
5860#include < functional>
5961#include < iostream>
@@ -584,7 +586,11 @@ int main(int argc, char* argv[])
584586 // true heap leak. malloc_trim(0) walks the top chunk of every arena
585587 // and madvise(MADV_DONTNEED)s pages that are free. Cheap (~ms) on
586588 // typical heap sizes, returns 1 if it actually released memory.
589+ #if defined(__GLIBC__)
587590 int trimmed = ::malloc_trim (0 );
591+ #else
592+ int trimmed = 0 ; // malloc_trim is a glibc extension; no-op on macOS/MSVC
593+ #endif
588594 LOG_INFO << " [MEM] vmrss=" << vm_rss_kb << " kB"
589595 << " vmsize=" << vm_size_kb << " kB"
590596 << " vmdata=" << vm_data_kb << " kB"
You can’t perform that action at this time.
0 commit comments