Apparent native memory leak under sustained heavy use (RSS grows into multi-GB, JS heap stays flat)
Summary
Under sustained heavy usage (many consecutive agent turns over several hours), the OpenClaw gateway process's RSS memory grows into the multi-GB range and does not appear to be released, while the V8 JS heap stays flat. This strongly points to a native-memory leak in this plugin's LanceDB/embedding bindings rather than a JS-side leak.
Environment
- Plugin version:
1.1.0-beta.11 - OpenClaw version:
2026.9.5 - Config:
autoCapture: true,autoRecall: true,smartExtraction: true, retrieval modehybridwith reranking, embedding provideropenai-compatible(Jina),dbPathon local disk.
Observed behavior
- Gateway process RSS reached ~4.2–5.5 GiB (internal
rss_thresholdof 3.14 GiB exceeded,level=critical), twice in about a day, with a process restart in between. The second time it happened again in roughly 9 hours of continuous use. - Used OpenClaw's built-in
diagnostics.heapProfiletool during a live sample:heapUsedBefore≈407MB,heapUsedAfter≈401MBover a 5.7s window — i.e. the V8 heap was stable/not growing — while total process RSS stayed multiple GB above heap, consistent with off-heap/native growth rather than a JS object leak. ps -Ton the gateway process showed severaltokio-runtime-workerthreads alongside normal Node worker threads, consistent with Rust/native bindings (LanceDB) doing background work.- Once the gateway's internal "critical" memory threshold was hit, an unrelated-looking symptom appeared repeatedly: an internal MCP loopback server used to expose tools (e.g.
message) to the agent process started failing withPlugin inventory has retired; begin a new plugin operation., breaking the agent's ability to deliver replies until the gateway process was restarted. Not confirmed this is caused by this plugin specifically vs. memory pressure in general, but it coincided both times with this plugin's memory growth. - As a workaround we disabled
autoCapture,autoRecall, andsmartExtractionin the plugin config and are monitoring whether RSS growth slows down.
Repro hints
Heaviest load scenario: one agent in continuous multi-hour conversation/task activity (dozens of turns/hour), smartExtraction and autoRecall both enabled, hybrid retrieval with reranking on every recall.
What would help
- Any guidance on whether
autoCapture/autoRecall/smartExtractionare known to retain native memory across calls (e.g. unreleased LanceDB connections/cursors, embedding client buffers, reranker request objects). - Whether there's a recommended interval for cycling/recreating the LanceDB connection to release native memory.
Happy to share full gateway logs / heap profile JSON privately if useful — didn't want to paste large internal log excerpts into a public issue.
Thanks for separating heap from RSS; that's the right first cut.
On current master, MemoryStore opens one LanceDB connection (lancedb.connect in src/store.ts) and keeps it for the store's lifetime, so per-call connections aren't the obvious source. Things that would narrow it down:
- Feature bisect. You already disabled
autoCapture/autoRecall/smartExtractiontogether. If RSS stays flat now, re-enable them one at a time (autoRecall+ hybrid/rerank alone first, thensmartExtraction). That tells us whether the growth follows recall/search or the write path. - Store instances. Does the gateway re-register the plugin during that 9 h window (config reload,
cli-metadatapasses, restarts of the plugin service)? A count ofmemory-lancedb-proregistration/init log lines over time would show whether new stores (and native handles) are being created without the old ones being released. - Native allocator.
tokio-runtime-workerthreads are LanceDB's. A run withMALLOC_ARENA_MAX=2(glibc) would show whether this is fragmentation rather than a true leak.
The first data point would say most. #1007 targets this issue, but it only releases handles in destroy(), so it would only help if (2) turns out to be the cause.