Summary
On macOS, electrobun dev --watch (the hutch-engine process) leaks memory. It grows by roughly 50–100 MB for each file-change event and never releases it. After about an hour of normal editing it reached ~12.7 GB physical footprint. The app itself (the bun main process and its WebKit view) stays at about 1 GB. A built app isn't affected.
Environment
- Electrobun 2.0.2 (
~/.hutch/npm/electrobun/2.0.2/macos-arm64/bin/hutch-engine) - macOS 27.2 (26B5091g), arm64
- Node 24.14.0, pnpm 12.11.2 (workspace monorepo), Bun 1.4.2
build.mainProcess: "bun",bundleCEF: false(system WebKit)- Run as
electrobun dev --watch, withbuild.watchIgnore: ["dist/**", "native/**", "src/client-runtime.ts"]
Observations
From vmmap --summary <hutch-engine pid> after ~66 min of uptime:
Physical footprint: 11.7G
Physical footprint (peak): 11.7G
REGION TYPE VIRTUAL RESIDENT DIRTY SWAPPED ...
Untagged 11.7G 16.2M 16.2M 11.7G ...-
Nearly all of the footprint is in the Untagged region (anonymous mmap, not malloc). It is compressed or swapped out, so
psRSS shows only ~70 MB, while Activity Monitor shows the full amount. Activity Monitor counts it under whatever terminal launched it (Cursor in my case). -
Only ~11 file descriptors are open, so it isn't leaking file handles or watchers.
-
Each file change grows it, whether or not the app relaunches. I tracked the
Untaggedswapped size while touching files:Action Untagged baseline 12.2G touch packages/gui/src/main.tsx(app not relaunched)12.3G touch packages/core/src/.../env.ts(app not relaunched)12.4G touch README.md(repo root, outside the app dir)12.5G touch packages/server/.../ApiRouter.ts12.5G -
With no edits it still creeps up about 0.1 GB/min (12.6G → 12.7G over 90 s). This is probably from background writes elsewhere in the repo (editor, tsc, Vite caches), which also suggests the watcher covers more than the app directory.
Repro
- Run
electrobun dev --watchon macOS in a project inside a larger workspace. - Get the
hutch-enginePID and runvmmap --summary <pid> | grep -E "Physical footprint|^Untagged". toucha few files in the project, and some outside the app directory, a few times.- Run
vmmapagain: the footprint andUntaggedswapped size go up with each change and never come back down.
Expected
The watcher's memory should stay roughly constant across rebuilds and change events.
Notes
- I haven't tested the
2.0.3-beta.*releases. - Possibly related: the watcher seems to react to changes outside the app directory, such as the repo-root
README.md. If that's intended, it would help to document the default watch roots alongsidebuild.watch/build.watchIgnore.
Activity
0No activity yet.