Repository navigation
fix(player): AudioPlaybackHost/SoftwarePlaybackHost memory leaks. - #213
Conversation
cdc74fa to
1f68f81
Compare
4c3a461
into
superuser404notfound:main
|
Merged, thank you. This was a well-run report from start to finish: the diagnosis was right, the before/after memprobe pair from the device makes the result unambiguous (physFP flat at ~163 MB across 13 minutes where it previously climbed 174 -> 451 MB linearly, and mallocBlocks plateaus at ~916k instead of running away), and the control-flow rewrite from break/continue into the One gap remained, so I swept it in a follow-up (08b4973): the background audio-only pacing gate in The fix ships in the next release. |
Summary
Resolves memory leaks in
SoftwarePlaybackHost/AudioPlaybackHoston long running loops by wrapping them inautoreleasepool.Closes #205
What changed
Sources/AetherEngine/Native/SoftwarePlaybackHost.swift(130 lines, +88/-42)Extracted the body of each of the four dispatch-block loops into a local
*Iteration() -> Boolfunction, replacingbreak/continuewithreturn false/return true. The outerwhile !stopRequested()then calls it insideautoreleasepool:readerIteration()demuxQueuepumpIteration()feedQueuefeederIteration()feedQueuedemuxIteration()demuxQueueAdditionally, 5 inner wait/poll loops that can spin for extended periods within a single outer iteration got their own
autoreleasepooldrains:feederIteration()pausedcondition.wait(until: Date(…))(every 0.5 s)feederIteration()live-edgecondition.wait(until: Date(…))(single wait)feederIteration()video back-pressureThread.sleep(0.005)/isReadyForMoreMediaDataspindemuxIteration()pausedcondition.wait(until: Date(…))(every 0.5 s)demuxIteration()back-pressure poll with nested paused wait — outer body wrapped inautoreleasepool, innercondition.waitalso gets its own drainSources/AetherEngine/Audio/AudioPlaybackHost.swift(45 lines, +31/-14)Same pattern applied to
runDemuxLoop, which previously had zeroautoreleasepoolusage:demuxIteration() -> Boolwhilecall inautoreleasepool { demuxIteration() }autoreleasepool:condition.wait(until: Date(…))Thread.sleep(0.05)Thread.sleep(0.1)— usesautoreleasepool { if seekedAway { … } else { … } }+ post-poolbreakcheck so theseekedAwayescape path works correctlyTest plan
Note: before/after memory logs attached.
Checklist
CHANGELOG.mdupdatedfeat(...),fix(...),chore(...))memprobe-opus-audio-host-before.txt
memprobe-livetv-software-host-after.txt
memprobe-livetv-software-host-before.txt
memprobe-opus-audio-host-after.txt