🐛 export: fix free_buffers memory leak on single-plane exports - #4
Merged
Merged
Conversation
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>
Contributor
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 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_framesthe writer recycles every finishedProducedFrame::Bytesinto thefree_bufferspool, but buffers are only ever popped back out inside thedual_planeproducer 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
🧪 Validation & Testing
cargo fmt --check— cleancargo clippy -- -D warnings— cleancargo check— cleanbun run typecheck/bun run test— Rust-only diff; covered by CITested on target operating systems:
📋 Checklist
free_buffers(why pushes are gated ondual_plane)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