Skip to content
OBLAIDISH NEWS
36gb memory leak in claude code server
TX_108095Engineering

36gb memory leak in claude code server

A 36GB RSS leak in a Claude Code memory server was caused by sql.js's in-memory filesystem retaining a full copy of each 11MB database per request, exposing Node's GC limits for native buffers [DevTo].

A production Claude Code memory server accumulated 36GB of RSS over six weeks before the cgroup OOM-killer terminated the process [DevTo]. The root cause was identified as sql.js's MEMFS retaining a full copy of each 11MB database per request [GitHub]. The service is a Node 22/Express proxy that spawns a child MCP process and forwards HTTP calls to it. The child loads sql.js – SQLite compiled to WebAssembly – and uses it to hold a key-value store in memory. Each request creates a new SQL.Database instance by reading the on-disk memory.db (≈11MB) into a MEMFS file via FS.createDataFile. The wrapper object is later garbage-collected, but the MEMFS file remains because the WASM module does not free native buffers automatically [Node 22 Release]. Over hundreds of requests, the process accumulated roughly 200 × 11MB files, pushing RSS to 36GB. The leak was visible in process.memoryUsage(): heapTotal stayed at 24MB while external and arrayBuffers grew past 1GB. A heap snapshot showed only 18MB of JS objects but retained 203 native:system/JSArrayBufferData nodes, each 11MB – exactly the size of the on-disk database. The inspector was attached via kill -USR1 <pid> and a 30-line WebSocket script, a feature added in Node 22. To fix the leak, the author patched the service to cache a single SQL.Database per database path, eliminating repeated MEMFS allocations. A lightweight RSS watchdog that respawns the child process also caps memory usage. Native buffers bypass V8 limits, and WASM MEMFS is a hidden source of leaks. Providing a standard API in Node to enumerate and free native buffers would prevent similar leaks in the growing ecosystem of WebAssembly-enabled services.

operator_channel
[ comments_offline · provider_not_configured ]
transmission_log

Subscribe to the broadcast.

Daily digest of the day's most important tech news. No fluff. Engineering signal only.

// delivered via substack · double-opt-in confirmation