N.03 / MEMORY
Boundedness is not one 68 MB number: four memory layers and 100,008 fds
Process RSS, kernel side, system total and per-connection marginal cost. 32.1 MB at 2,000 connections, 55.6 MB at 50,000, and why a step is not a leak.
Scope: the local five-way memory round (2,000 held connections and churn) and a 50,000-connection scan; the production window is covered in N.02. Numbers come from the public repository’s docs/sodama-atlas.html §4.3/§4.6 and the raw final-mem.tsv / mem-system-*.tsv files under docs/reviews/2026-10-16-local-full-bench/.
Four layers, not one RSS
“Memory use” has at least four scopes: process RSS, kernel side (eBPF / socket / softirq), system total, and per-connection marginal cost. Process RSS alone misses kernel cost; system total alone hides userspace differences. Measure all four before making a tradeoff.
| Implementation | idle | hold 2,000 | churn peak | settle 30 s | per connection |
|---|---|---|---|---|---|
| sodama | 29.3 | 32.1 | 32.9 | 32.3 | ≈1.4 KB |
| sing-box | 57.9 | 84.3 | 92.3 | 73.3 | ≈13.2 KB |
| v2ray | 45.3 | 143.3 | 484.8 | 314.4 | ≈49 KB |
| mihomo | 47.6 | 171.0 | 229.3 | 69.9 | ≈62 KB |
| dae v2.1.1 | 49.7 | 302.4 | 343.1 | 81.8 | ≈126 KB |
At 2,000 connections sodama uses 32.1 MB, about 1.4 KB per connection; the churn peak is 32.9 MB and it settles back to 32.3 MB after 30 seconds. v2ray’s 484.8 MB churn peak and 314.4 MB settled value show allocator retention; dae’s 302.4 MB steady point is GC retention. The difference is not just “who is smaller” but “who gives the memory back after pressure”.
50,000 connections: 100,008 fds and system total
In the 50,000-connection scan, sodama reaches 55.6 MB RSS, 31 threads and 100,008 fds; 100,008 ÷ 50,004 connections = 2 fds per connection, exactly the two sockets (LAN/WAN side). Pipes are lazy and released when idle, so they are not a constant fd cost. On the system-total layer sodama adds about 2.0 GB (≈40.9 KB per connection, including shared links), while dae adds about 8.2 GB (172.7 KB per connection). An RSS advantage is not a system advantage; measure both layers.
A step is not a leak
The local 60-minute soak raised RSS by 17.6%, which fails the criterion, but the shape was a single 4.5 MB step, not sustained growth: Slab +0.26%, SUnreclaim +0.88%, no fd growth, zero failures, RTT p50 44 µs. The result was queued for a 2–3 hour retest, not labelled a leak. The criterion looks at the steady-state slope and the window rangeRange is max minus min inside the window, not a standard deviation: it answers “did it drift”, not “how much did it wobble”.: a one-time lift and a permanently positive slope are different shapes.
| Window | Start | Steady / plateau | Range | Slope |
|---|---|---|---|---|
| Local 60 min | — | RSS +17.6% (fails criterion) | single 4.5 MB step | not sustained |
| Production 21.4 h | 43.8 MB | 53.5 MB | 3.66 MB over 14 h | −47.8 KB/h ≈ 0 |
| Production 78.5 h | 53.2 MB | 66.7 MB | 2.0 MB over 46 h | ≈ 0 |
In the production round, RSS correlates with cumulative connections at +0.48, so the working set follows traffic; 78.5 hours passed without a restart, and the 92.9 MB evening peak fell back. This still does not justify “bounded memory”: the criteria are ≤5% RSS/FD drift in the steady state, zero growth in failure counters, zero stragglers, no restart, with checkpoints at 24/48/72 hours; a one-week round adds 120/144/168 hours. 60 minutes is not 72 hours, and 72 hours is not forever.
How to read these numbers
- 2,000 connections is the steady-state scope, churn is the pressure scope, 50,000 is the scale scope; do not merge them into one sentence.
- RSS and system total both matter; reporting only one hides cost in the other layer.
- fds are part of the resource boundary: 2 fds per connection means 4,096 concurrent connections need about 8,192 fds, not 12,000.
- Before calling a step a leak, check the slope and the range.
Boundedness is not a 68 MB headline. It is four scopes, a slope, a set of failure counters and an explicit time window. Remove one, and the number becomes decoration.
Sources: public repository docs/sodama-atlas.html §4.3, §4.6 and §8; raw memory TSVs under docs/reviews/2026-10-16-local-full-bench/; safety audit in docs/memory-safety-audit.html.
FOOTNOTES