Skip to content

Commit e967221

Browse files
authored
Merge pull request #94 from frstrtr/ci-steward/release-validate
fix(btc): guard glibc-only malloc_trim behind __GLIBC__ (release-matrix macOS/Windows)
2 parents 912a06e + aa7c0a5 commit e967221

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/c2pool/main_btc.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@
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"

0 commit comments

Comments
 (0)