Cap glibc malloc arenas to keep non-Go RSS bounded (closes #23) #24

Merged
clawbot merged 1 commits from issue-23-malloc-arena into next 2026-09-21 19:29:32 +02:00
1 Commits
Author SHA1 Message Date
sneak e7cc8859c1 Cap glibc malloc arenas to keep non-Go RSS bounded (closes #23)
check / check (push) Failing after 1s
After the earlier memory work, SQLite's live heap is bounded but process
RSS still climbed about 70 MiB/min, nearly all anonymous and outside the
Go runtime and outside SQLite's own accounting, without any SQLITE_NOMEM.
The cause is glibc: the SQLite C library allocates and frees millions of
small page-cache chunks from many threads, and glibc keeps each arena's
freed chunks resident. With arenas uncapped it creates up to eight per
core, so on a large host RSS grows with the core count.

Set MALLOC_ARENA_MAX=2 in the image to bound the retained memory. Writes
are already serialized, so the two-arena cap costs no throughput. Update
the README Memory section.

Model: opus-4-8
2026-09-21 16:08:44 +00:00