Repository navigation
Engine: Drain autoreleased chunks on the feeder, pump and waveform threads - #552
Merged
Merged
Conversation
…reads The feeder and pump threads run their loops with no autorelease pool of their own, so every autoreleased object a pass makes (the Float32 chunks ChunkList's removeSamplesAsFloat32 and convertChunk hand back, and their data) lived until the thread ended: the footprint grew for as long as playback went on, about 1 MB/s with a decoder that returns one ~20 ms chunk per readAudio. The waveform scanner drained its pool only per decoded chunk, so a whole track's converted blocks piled up while it scanned (hundreds of MB for a long track of small chunks). Wrap the feeder's feed(chunk), each pump pass, and each scanned block in an autoreleasepool.
|
I ran into the same problem as #551: after long playback, memory kept growing until it filled the system's memory. With this PR's changes, I played continuously for 1 hour and did not see the continuous memory growth. Memory usage stayed below 200 MB. Setup
|
kddlb
added a commit
that referenced
this pull request
Nov 9, 2026
#552 pooled only feed(chunk), so what a seek, a reset or a track change autoreleased (opening the next decoder, its properties) still lived as long as the feeder thread. Put the whole pass in the pool instead, with the loop body moved into pass(), as the pump does. Inside feed(), drain per 4096-frame block rather than per decoded chunk, as the waveform scanner now does, so a decoder that returns large chunks doesn't hold all their converted blocks at once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
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.
Fixes #551.
The feeder and pump threads loop without an autorelease pool of their own, so every autoreleased object a pass makes (the Float32 chunks
ChunkList'sremoveSamplesAsFloat32/convertChunkhand back, and their data) lived until the thread ended. The waveform scanner drained only per decoded chunk, so a whole track's converted blocks piled up while it scanned.This change wraps each of these in an
autoreleasepool:feed(chunk)inFeeder.run()pass()inPump.run()WaveformScanner(the block body returns next / stop / done, sobreakandreturn truekeep their meaning)Tested on macOS 15.8.1 arm64 with a Debug build:
leaksfinds 880 bytes, all UI.engineCaptureDirectory, is sample for sample equal to the decoder's PCM.