Engine RSS grows without bound on Linux gnu builds: glibc malloc arena retention; MALLOC_ARENA_MAX=2 holds it flat
Author: david-waltermireCreated Sep 30, 2026Updated Oct 1, 2026
Summary
On Linux gnu builds, the engine's RSS grows without bound after boot, and the growth is not live data. It is glibc malloc arena retention. Across many per-thread arenas, glibc keeps memory from large transient allocations and never returns it to the OS. MALLOC_ARENA_MAX=2 holds RSS flat with no measurable latency cost.
Environment
- Engine 0.22.1,
x86_64-unknown-linux-gnu, run under systemd. - Workload: agentmemory, a Node worker. The state store is
file_based, about 1.4 GB on disk. engine/Cargo.tomlonmain(0.24.4-rc.1) declares no global allocator (no jemalloc, mimalloc or snmalloc crate), and the binary importsmalloc@GLIBC_2.2.5. So I expect current gnu builds to behave the same way.
Measurements
RSS after a restart, with the same workload and store:
| Time after boot | 1 min | 3 min | 5 min | 8 min | 9 min | 11 min |
|---|---|---|---|---|---|---|
| Default allocator settings | 5.0 GB | 7.4 GB | 8.6 GB | 10.8 GB | 12.9 GB | 14.0 GB |
MALLOC_ARENA_MAX=2 |
5.3 GB | 5.8 GB | 5.8 GB | 5.8 GB | 5.8 GB | 5.8 GB |
- The growth is arenas. At 11 minutes with default settings,
/proc/<pid>/smapsshowed 11.6 of 14.4 GB in 120 anonymous regions of 64 to 131 MB each. That is glibc's per-thread arena heap shape. The process had 30 threads, and glibc allows up to 8 arenas per core. - With
MALLOC_ARENA_MAX=2, anonymous memory stayed at 1.2 GB in 12 regions. - Latency did not change:
/healthabout 3 ms, list endpoints 40 to 550 ms, and search about 130 ms. - Growth rises in steps of up to about 2 GB within one 30-second interval, which suggests large transient buffers such as big
state::listresults or state-file saves.
Suggestion
One of these:
- a global allocator for the gnu build (jemalloc and mimalloc both return memory far more readily), or
- documenting
MALLOC_ARENA_MAX=2for long-running engines.
The musl build uses a different allocator, and I have not measured it.
Source: iii-hq/iii