Skip to main content

Module heap

Module heap 

Source
Expand description

The glibc arena cap the daemon starts under, and allocator residency accounting for /v1/status.

The daemon runs under a hard MemoryMax and has twice been cgroup-OOM- killed on anonymous RSS with no retained structure anywhere near the size of the resident set: the store holds ~12k memories (~18 MB of embeddings) while RSS sits above 1.7 GB. Anonymous RSS alone cannot say whether those bytes are live data or memory the allocator has taken from the kernel and not given back, and that distinction picks the remedy: freed-but-retained bytes point at glibc’s per-thread arenas, whose non-main arenas only ever trim their top chunk, while live bytes point at a working set that simply does not fit the cap.

mallinfo2 aggregates every arena, and glibc is where both the Rust side and the C/C++ libraries that use malloc (onnxruntime, sqlite) get their memory; usearch maps its own tapes, which the component report counts.

Structs§

HeapReport
HeapStats plus where the anonymous resident set goes, per component.
HeapStats

Constants§

ARENA_CAP

Functions§

arena_mappings
cap_arenas
Caps glibc at ARENA_CAP malloc arenas unless MALLOC_ARENA_MAX is set. Threads that already allocated keep their arena, so call it before any thread starts.
component_residency
heap_report
Takes the reader index lock briefly, so call it off the async runtime.
heap_stats
record_index_writer
What the drain loop’s writer Indexes holds, or None while it is released. Process-wide, like the RSS it is compared against.