Main process (not renderer) crashes with V8 heap OOM at ~4 GB on macOS (3.24.9 and 3.24.12): heap climbs silently ~5–9 MB/s after launch

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

Where does the bug appear? Cursor main (browser) process, macOS desktop app

Does this stop you from using Cursor? Yes. It quits unexpectedly several times a day.

Describe the bug

Cursor’s main process runs out of V8 heap and the whole app exits. The existing OOM threads I found are about the renderer; this is the Electron main process (event.process: browser in the crash report).

The report’s v8-oom fields:

field value
location Ineffective mark-compacts near heap limit
heap limit 4,096 MB
heap used 3,994 MB (97.5%)
old_space 3,829 MB
large-object space 164 MB
malloced / external 64 MB / 7 MB

9 of my last 10 launches begin with an OOM report from the previous run (older logs have already rotated, so I can’t say when it started). It happens on both 3.24.9 and 3.24.12.

What I measured

The heap climbs monotonically after a normal start. A fresh launch sits at roughly 100–450 MB (normal GC sawtooth), then enters a runaway phase of ~5–9 MB/s at 60–90% CPU until it hits the limit. I sampled the main process every 10 s using the macOS footprint “app-specific tag 16” region as a heap proxy. It tracked the crash report closely (3,844 MB sampled just before the crash vs 3,994 MB reported). One run:

time since launch heap proxy
~3 min 303 MB
~9 min 973 MB
~11 min 1.5 GB
~14 min 2.7 GB

No agent activity is needed. During the climb, no agent run was active (the agent-loop wakelock had been released minutes earlier), the hook-call counter was flat, and the app wrote nothing to its logs.

sample of the main process during the climb (5 s):

  • three libuv worker threads each ~23% busy in stat / open / getdirentries64 / close, i.e. a recursive filesystem walk through Node fs
  • the main thread spends its time in V8 GC tracing (cppgc) and microtask processing
  • no JS frames are available from sample, so I can’t say which code is walking

What I ruled out

  • System memory: 48 GB RAM, ~90% free, no swap, no jetsam or kernel panic.
  • Chat history size: a fresh launch loads the same ~19 GB state.vscdb and sits at ~300 MB until the climb starts. Archiving doesn’t help either (1,277 of ~1,950 chats are already archived and their data stays in the DB).
  • ai-code-tracking.db: only 59 MB.

Possibly relevant setup

  • One very large monorepo workspace with ~20 git worktrees (some under Cursor’s managed worktrees folder, some elsewhere).
  • Every session logs WorktreeCleanupMainService ... Granted cleanup lease ... reason="startup-catchup-worktree-cleanup" and never logs it being released. I can’t tell whether that is the walker.
  • Every session also reports WorkingCopyLeakError: Potential working copy LEAK detected, having 513 working copies already. Most frequent owner (258).

Questions

  1. Is this main-process OOM known? I couldn’t find a matching report.
  2. Is there a supported way to trace what the main process is walking (or to cap it)?
  3. What should I capture next? I can take a heap snapshot of the main process if you tell me the preferred method.

Version info

  • Cursor 3.24.12 (also reproduced on 3.24.9), Electron 42.10.0
  • macOS 26.6.2, Apple M5 Pro (arm64), 48 GB RAM

Steps to Reproduce

Possibly relevant setup
One very large monorepo workspace with ~20 git worktrees (some under Cursor’s managed worktrees folder, some elsewhere).
Every session logs WorktreeCleanupMainService … Granted cleanup lease … reason=“startup-catchup-worktree-cleanup” and never logs it being released. I can’t tell whether that is the walker.
Every session also reports WorkingCopyLeakError: Potential working copy LEAK detected, having 513 working copies already. Most frequent owner (258).

Operating System

MacOS

Version Information

Version info
Cursor 3.24.12 (also reproduced on 3.24.9), Electron 42.10.0
macOS 26.6.2, Apple M5 Pro (arm64), 48 GB RAM

Does this stop you from using Cursor

Yes - Cursor is unusable

Update: a workaround that seems to stop it (cause still unconfirmed)

I made two changes at once, so I can’t yet say which one mattered:

  1. Downgraded to 3.23.23 (official build from the downloads page).
  2. Added these to settings.json:
"cursor.worktreesGlobalMaxSizeGb": 0,
"cursor.worktreeCleanupIntervalHours": 500,
"update.mode": "none"

(update.mode: none only stops it auto-updating back to 3.24.)

Result so far: the main process sits at ~65 MB (peak 227 MB right at startup) with ~0% CPU, 8+ minutes after launch. On 3.24.12 the same workspace was already at 500+ MB and climbing ~5–9 MB/s by this point, and it eventually hit the 4 GB limit. I’ll update this if it crashes later.

Why I tried those settings (hypothesis, not proven): reading the bundled app code, I found that:

  • Cursor runs a “startup catch-up” worktree cleanup if the last completed cleanup is older than cursor.worktreeCleanupIntervalHours (default 6 h).
  • It records success only after the cleanup finishes. Mine last completed ~38 h before the crashes, so every launch started it again.
  • The size cap (cursor.worktreesGlobalMaxSizeGb, default 50) makes it measure the size of every worktree. That goes through a main-process directory walker that does a readdir + lstat on every entry. My ~/.cursor/worktrees reports ~2.8 TB logically (APFS clones inflate this), which matches the sample of the main process showing libuv threads busy in stat/open/getdirentries.
  • The code treats 0 for the size cap as “disabled”.

Warning if you try this: don’t set the interval to a huge number. Above ~596 hours (the 32-bit timer limit) the schedule fires immediately and loops: I set 100000 first and got ~200 cleanup runs per second until I lowered it. 500 is safe.

What would confirm it: running 3.24.12 with just these settings (no downgrade). I haven’t tried that yet. If you have many or large git worktrees under ~/.cursor/worktrees and a main-process OOM, it may be worth checking whether worktree.cleanupLastRunAtMs in state.vscdb is stale.

Could someone from Cursor confirm whether the cleanup’s size scan is expected to walk every worktree in the main process, and whether it is bounded?

Hey @Shahzad_Muhammad, thanks for the update and for tracking this down.

Your read is right. The automatic worktree cleanup measures the size of each Cursor-managed worktree by walking every file in it (everything except .git), and that walk currently has no upper limit. With worktrees as large as yours it can exhaust the main process’s memory, and because the run never finishes, it starts over on the next launch. I’ve flagged this to the team, along with the interval loop you found above roughly 596 hours.

The downgrade shouldn’t be needed. The cleanup code is the same in 3.23 and 3.24, so the settings are what fixed it. If you’d like to confirm, you can move back to 3.24 and keep:

"cursor.worktreesGlobalMaxSizeGb": 0,
"cursor.worktreeCleanupIntervalHours": 500

Then remove "update.mode": "none" so you keep getting updates. If memory still climbs on 3.24 with those settings, please let me know.

One note: with the size limit off, Cursor still keeps at most 25 managed worktrees, and it measures each one it removes. So it’s worth clearing out old, large worktrees under ~/.cursor/worktrees that you no longer need.