Skip to content

🐛 export: fix free_buffers memory leak on single-plane exports - #4

Merged
jeandedieuH merged 1 commit into
mainfrom
devin/1790058017-fix-overlay-pool-leak
Sep 22, 2026
Merged

jeandedieuH merged 1 commit into
mainfrom
devin/1790058017-fix-overlay-pool-leak

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

📝 Description

Fixes the OOM crash reported when running exports on tauri:dev (memory allocation of 7570752 bytes failed → STATUS_STACK_BUFFER_OVERRUN).

Root cause: in feed_cursor_frames the writer recycles every finished ProducedFrame::Bytes into the free_buffers pool, but buffers are only ever popped back out inside the dual_plane producer branch. On a single-plane stream — cursor-only or items-only — nothing consumes the pool, so it grows by one plate (~7–8 MiB) per frame. A 60 s export at 30 fps leaks ~14 GB of dead Vecs until the allocator fails — matching the reported ~7.5 MB failed allocation (a screen-rect plane) exactly.

The bug came in with the overlay worker-pool refactor (929c9d1), one commit before #3 — it is not caused by the screen-rect plate change, which only shrinks each leaked buffer slightly.

Fix: gate the recycle push on dual_plane. Single-plane frames are dropped after the write as before; dual-plane recycling is unchanged. One-word gate, no behavioural change to output.

🎯 Type of Change

  • 🐛 Bug fix (non-breaking change fixing an issue)

🧪 Validation & Testing

  • cargo fmt --check — clean

  • cargo clippy -- -D warnings — clean

  • cargo check — clean

  • bun run typecheck / bun run test — Rust-only diff; covered by CI

  • Tested on target operating systems:

    • Windows (compile-verified; the export loop itself needs a real export run)
    • macOS
    • Linux

📋 Checklist

  • Style follows existing conventions
  • Non-obvious decision commented at free_buffers (why pushes are gated on dual_plane)
  • No raw frames/secrets across Tauri boundaries
  • No telemetry added

Link to Devin session: https://app.devin.ai/sessions/52c7ba7f829f4aecbefa2f889efc8dc5
Open in Devin Desktop: https://app.devin.ai/desktop/session/52c7ba7f829f4aecbefa2f889efc8dc5?variant=devin
Requested by: @jeandedieuH

The writer recycled every finished frame buffer into free_buffers, but
buffers are only popped back out in the dual-plane producer branch. On
single-plane exports (cursor-only or items-only) the pool therefore grew
by one plate per frame (~7-8 MiB) until the process ran out of memory:
~14 GB over a 60 s 30 fps export. Gate recycling on dual_plane.

Co-Authored-By: Jean de Dieu HAGENIMANA <jdhagena77@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@jeandedieuH
jeandedieuH merged commit 7143f2e into main Sep 22, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant