Sandboxed Worker using a lot of ram when doing nothing #41
-
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Hey @arthurvanl! Investigated this and confirmed the issue — SandboxedWorker child processes were never terminated when idle. With Root cause: The existing Fixed in v2.6.12 — added per-worker idle recycling via new
// Default behavior (v2.6.12+): workers recycle after 30s idle
const worker = new SandboxedWorker("queue", {
processor: "processor.ts",
concurrency: 3,
maxMemory: 512,
// idleRecycleMs: 30000 <- default, workers auto-terminate when idle
});
// Customize the recycle timeout
const worker2 = new SandboxedWorker("queue", {
processor: "processor.ts",
concurrency: 3,
idleRecycleMs: 60000, // recycle after 60s idle
});
// Disable recycling (old behavior)
const worker3 = new SandboxedWorker("queue", {
processor: "processor.ts",
concurrency: 3,
idleRecycleMs: 0, // never recycle
});You can also check recycled workers via const stats = worker.getStats();
// { total: 3, busy: 0, idle: 1, recycled: 2, restarts: 0 }This should significantly reduce your idle RAM usage. Let me know if you still see issues after upgrading! |
Beta Was this translation helpful? Give feedback.



Hey @arthurvanl!
Investigated this and confirmed the issue — SandboxedWorker child processes were never terminated when idle. With
concurrency: 3andmaxMemory: 512, that's ~1.5 GB of RAM sitting idle doing nothing.Root cause: The existing
idleTimeoutoption (default: 0 = disabled) stops the entire pool, which also prevents new cron jobs from being processed. There was no mechanism to recycle individual worker processes.Fixed in v2.6.12 — added per-worker idle recycling via new
idleRecycleMsoption: