Cap icon indicating copy to clipboard operation
Cap copied to clipboard

fix: window memory leak - memory increase while recording

Open phuocithcmus opened this issue 1 month ago • 1 comments

Summary by CodeRabbit

  • Refactor
    • Optimized memory management in video encoding processing to improve efficiency and stability.

phuocithcmus avatar Nov 12 '25 09:11 phuocithcmus

Walkthrough

Memory management optimization in H.264 video encoding MediaFoundation binding. The code now directly consumes samples from output buffers instead of cloning, reducing unnecessary allocations while maintaining identical control flow and error handling semantics.

Changes

Cohort / File(s) Summary
Memory Management Refactor
crates/enc-mediafoundation/src/video/h264.rs
Eliminated sample cloning in METransformHaveOutput handling by directly extracting pSample from the output buffer and consuming it in place; preserved error path when no sample is produced; added ownership clarification comment

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Specific areas requiring attention:
    • Verify that direct pSample consumption does not bypass required cleanup or reference counting in the MediaFoundation API
    • Confirm error path behavior remains equivalent when the output buffer contains no sample

Poem

🐰 A sample once cloned, now flows free, Through buffers direct, no copy spree! Memory dances lighter still, H.264 hops with better will. 🎬

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: fixing a memory leak in the H.264 video encoder by optimizing METransformHaveOutput memory handling to prevent cloning samples.
✨ Finishing touches
  • [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Nov 12 '25 09:11 coderabbitai[bot]

Thanks for this!!

richiemcilroy avatar Nov 20 '25 15:11 richiemcilroy