MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cbm_mem_allocator_committed

Function cbm_mem_allocator_committed

src/foundation/mem.c:581–594  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

579}
580
581size_t cbm_mem_allocator_committed(void) {
582 size_t commit = 0;
583 mi_process_info(NULL, NULL, NULL, NULL, NULL, &commit, NULL, NULL);
584 /* The statistic behind this is a signed counter merged per thread at
585 * thread exit; a process whose long-lived thread commits what its
586 * short-lived threads free reads it NEGATIVE, cast to size_t here. The
587 * daemon's query-leak soak reported 2^64 - 121 MB from the second sample
588 * on (Linux, 2026-09-14). A negative reading is no reading: report 0 so
589 * the charge falls back to the OS number instead of a 16 EB budget breach. */
590 if (commit > (SIZE_MAX >> 1)) {
591 return 0;
592 }
593 return commit;
594}
595
596static _Atomic size_t g_peak_charged;
597static _Atomic size_t g_charged_for_tests; /* 0 = live reading */

Callers 3

write_diagnosticsFunction · 0.85
pp_charge_probeFunction · 0.85
log_phase_memFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected