Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
fix(mem): no glibc malloc_trim; the static Linux release links again
Martin Vogel172787de9c18
diff --git a/src/foundation/mem.c b/src/foundation/mem.cindex 753e101f9..48f0eeeff 100644--- a/src/foundation/mem.c+++ b/src/foundation/mem.c@@ -35,9 +35,6 @@#include <malloc/malloc.h> /* malloc_zone_pressure_relief */#else#include <unistd.h>-#if defined(__GLIBC__)-#include <malloc.h> /* malloc_trim */-#endif#endif/* Does THIS build ask mimalloc to replace ordinary malloc process-wide?@@ -606,11 +603,15 @@ size_t cbm_mem_footprint(void) {}void cbm_mem_release_to_os(void) {+ /* mi_collect is the release: on Linux and Windows mimalloc owns malloc, so+ * there is no libc heap to trim. glibc's malloc_trim was called here once+ * and cost the static Linux release its link: the reference pulls+ * libc.a(malloc.o) in beside mimalloc's malloc/free (multiple definition,+ * release run 34948714902, 2026-09-15). macOS keeps the system heap for+ * everything outside the core, hence the pressure-relief call there. */mi_collect(true);#if defined(__APPLE__)(void)malloc_zone_pressure_relief(NULL, 0);-#elif defined(__GLIBC__)- (void)malloc_trim(0);#endif}diff --git a/src/foundation/mem.h b/src/foundation/mem.hindex 9b318fc9e..8fe909f0e 100644--- a/src/foundation/mem.h+++ b/src/foundation/mem.h@@ -119,9 +119,11 @@ void cbm_mem_collect(void);size_t cbm_mem_footprint(void);/* Hand freed memory back to the OS on every allocator this process uses:- * mimalloc (mi_collect), the macOS system zones (malloc_zone_pressure_relief)- * and glibc (malloc_trim). Costs a few ms; call at phase boundaries after a- * bulk release, never per allocation. */+ * mimalloc (mi_collect) and, on macOS, the system zones+ * (malloc_zone_pressure_relief). Never glibc's malloc_trim: on Linux mimalloc+ * owns malloc, and the reference alone breaks the static release link. Costs+ * a few ms; call at phase boundaries after a bulk release, never per+ * allocation. */void cbm_mem_release_to_os(void);/* ── Memory map: where does the process's memory actually live? ──────