Skip to content

Long running SoftwarePlaybackHost live sessions result in host app being terminated due to memory pressure #205

Closed

Description

@nathanpiper

What happened?

Playing a long running live TV session on a host app (Sodalite) results in the app being terminated due to memory pressure (JetsamEvent).

Looking at the logs you can observe a sizeable memory leak on the heap.

I have a forked fix that wraps the demux, reader, feeder, pumpAudio loops in an autoreleasepool on each iteration. This resolves the issue.

I can raise a PR if that would be helpful?

Steps to reproduce

  1. Open a live tv software playback session
  2. Observe host app termination (after 30m-1 hour or so).

AetherEngine version or commit SHA

5.20.2

Host app

Sodalite

Platform

tvOS

OS version

tvOS 26.5

Device / chip

Apple TV 4K (3rd Gen)

Playback path

Software (dav1d) host

Source media (for playback bugs)

Live TV

Error codes / log lines

[AetherEngine] memprobe t=30s rss=267MB vmInt=126MB vmExt=105MB vmCmp=0MB vmIOS=0MB physFP=178MB mallocBlocks=477114 mallocMB=228 avioFetchedMB=0 cacheCount=0 cacheMB=0 packetsWritten=0 audioFifo=0 abFifoKB=0 abSwrKB=0 abTotKB=0 muxBytesMB=0 muxCuts=0 srvConns=0 srvBytesMB=0 srvSfMB=0 pktAlive=0 pktTotal=0 subCues=0 audioTracks=1 subTracks=1 subActive=false avBufAhead=0.0s avBufBehind=0.0s frameAhead=0.00s prodShift=0.00s hostShift=0.00s seams=0
[AetherEngine] memprobe t=30s rss=267MB vmInt=126MB vmExt=105MB vmCmp=0MB vmIOS=0MB physFP=178MB mallocBlocks=477114 mallocMB=228 avioFetchedMB=0 cacheCount=0 cacheMB=0 packetsWritten=0 audioFifo=0 abFifoKB=0 abSwrKB=0 abTotKB=0 muxBytesMB=0 muxCuts=0 srvConns=0 srvBytesMB=0 srvSfMB=0 pktAlive=0 pktTotal=0 subCues=0 audioTracks=1 subTracks=1 subActive=false avBufAhead=0.0s avBufBehind=0.0s frameAhead=0.00s prodShift=0.00s hostShift=0.00s seams=0
[AetherEngine] memprobe t=60s rss=285MB vmInt=138MB vmExt=105MB vmCmp=0MB vmIOS=0MB physFP=190MB mallocBlocks=613559 mallocMB=261 avioFetchedMB=0 cacheCount=0 cacheMB=0 packetsWritten=0 audioFifo=0 abFifoKB=0 abSwrKB=0 abTotKB=0 muxBytesMB=0 muxCuts=0 srvConns=0 srvBytesMB=0 srvSfMB=0 pktAlive=0 pktTotal=0 subCues=0 audioTracks=1 subTracks=1 subActive=false avBufAhead=0.0s avBufBehind=0.0s frameAhead=0.00s prodShift=0.00s hostShift=0.00s seams=0
[AetherEngine] memprobe t=60s rss=285MB vmInt=138MB vmExt=105MB vmCmp=0MB vmIOS=0MB physFP=190MB mallocBlocks=613559 mallocMB=261 avioFetchedMB=0 cacheCount=0 cacheMB=0 packetsWritten=0 audioFifo=0 abFifoKB=0 abSwrKB=0 abTotKB=0 muxBytesMB=0 muxCuts=0 srvConns=0 srvBytesMB=0 srvSfMB=0 pktAlive=0 pktTotal=0 subCues=0 audioTracks=1 subTracks=1 subActive=false avBufAhead=0.0s avBufBehind=0.0s frameAhead=0.00s prodShift=0.00s hostShift=0.00s seams=0
[AetherEngine] memprobe t=90s rss=306MB vmInt=154MB vmExt=105MB vmCmp=0MB vmIOS=0MB physFP=205MB mallocBlocks=747051 mallocMB=305 avioFetchedMB=0 cacheCount=0 cacheMB=0 packetsWritten=0 audioFifo=0 abFifoKB=0 abSwrKB=0 abTotKB=0 muxBytesMB=0 muxCuts=0 srvConns=0 srvBytesMB=0 srvSfMB=0 pktAlive=0 pktTotal=0 subCues=0 audioTracks=1 subTracks=1 subActive=false avBufAhead=0.0s avBufBehind=0.0s frameAhead=0.00s prodShift=0.00s hostShift=0.00s seams=0
[AetherEngine] memprobe t=90s rss=306MB vmInt=154MB vmExt=105MB vmCmp=0MB vmIOS=0MB physFP=205MB mallocBlocks=747051 mallocMB=305 avioFetchedMB=0 cacheCount=0 cacheMB=0 packetsWritten=0 audioFifo=0 abFifoKB=0 abSwrKB=0 abTotKB=0 muxBytesMB=0 muxCuts=0 srvConns=0 srvBytesMB=0 srvSfMB=0 pktAlive=0 pktTotal=0 subCues=0 audioTracks=1 subTracks=1 subActive=false avBufAhead=0.0s avBufBehind=0.0s frameAhead=0.00s prodShift=0.00s hostShift=0.00s seams=0
[AetherEngine] memprobe t=120s rss=323MB vmInt=167MB vmExt=105MB vmCmp=0MB vmIOS=0MB physFP=218MB mallocBlocks=888864 mallocMB=339 avioFetchedMB=0 cacheCount=0 cacheMB=0 packetsWritten=0 audioFifo=0 abFifoKB=0 abSwrKB=0 abTotKB=0 muxBytesMB=0 muxCuts=0 srvConns=0 srvBytesMB=0 srvSfMB=0 pktAlive=0 pktTotal=0 subCues=0 audioTracks=1 subTracks=1 subActive=false avBufAhead=0.0s avBufBehind=0.0s frameAhead=0.00s prodShift=0.00s hostShift=0.00s seams=0
[AetherEngine] memprobe t=120s rss=323MB vmInt=167MB vmExt=105MB vmCmp=0MB vmIOS=0MB physFP=218MB mallocBlocks=888864 mallocMB=339 avioFetchedMB=0 cacheCount=0 cacheMB=0 packetsWritten=0 audioFifo=0 abFifoKB=0 abSwrKB=0 abTotKB=0 muxBytesMB=0 muxCuts=0 srvConns=0 srvBytesMB=0 srvSfMB=0 pktAlive=0 pktTotal=0 subCues=0 audioTracks=1 subTracks=1 subActive=false avBufAhead=0.0s avBufBehind=0.0s frameAhead=0.00s prodShift=0.00s hostShift=0.00s seams=0
[AetherEngine] memprobe t=150s rss=343MB vmInt=180MB vmExt=105MB vmCmp=0MB vmIOS=0MB physFP=232MB mallocBlocks=1011562 mallocMB=375 avioFetchedMB=0 cacheCount=0 cacheMB=0 packetsWritten=0 audioFifo=0 abFifoKB=0 abSwrKB=0 abTotKB=0 muxBytesMB=0 muxCuts=0 srvConns=0 srvBytesMB=0 srvSfMB=0 pktAlive=0 pktTotal=0 subCues=0 audioTracks=1 subTracks=1 subActive=false avBufAhead=0.0s avBufBehind=0.0s frameAhead=0.00s prodShift=0.00s hostShift=0.00s seams=0
[AetherEngine] memprobe t=150s rss=343MB vmInt=180MB vmExt=105MB vmCmp=0MB vmIOS=0MB physFP=232MB mallocBlocks=1011562 mallocMB=375 avioFetchedMB=0 cacheCount=0 cacheMB=0 packetsWritten=0 audioFifo=0 abFifoKB=0 abSwrKB=0 abTotKB=0 muxBytesMB=0 muxCuts=0 srvConns=0 srvBytesMB=0 srvSfMB=0 pktAlive=0 pktTotal=0 subCues=0 audioTracks=1 subTracks=1 subActive=false avBufAhead=0.0s avBufBehind=0.0s frameAhead=0.00s prodShift=0.00s hostShift=0.00s seams=0

Anything else

The root cause of these leaks seems to be long running (looping) GCD workloads, as the pool is drained on completion (vs structured concurrency where pools are drained on suspension).

Activity

  1. added
    bug
    on Jul 24, 2026
  2. superuser404notfound commented on Jul 24, 2026

    @superuser404notfound
    Owner

    Great analysis, and yes, a PR would be very welcome. Thanks for digging this deep before reporting.

    Your diagnosis matches what the probes say. Everything the engine tracks itself (packet ring, caches, audio FIFO) stays flat in your memprobe lines while mallocBlocks grows linearly, so the growth is untracked small allocations. Each of the SW host loops runs inside a single GCD work item that never returns for the lifetime of the session, so the thread's autorelease pool is never drained, and every ObjC/CF temporary from the per-iteration calls accumulates (the isReadyForMoreMediaData back-pressure polling, renderer/audio enqueue, the NSCondition.wait(until: Date(...)) date bridging, log formatting). The engine already drains per emitted frame inside SoftwareVideoDecoder for exactly this reason; the loops themselves were never wrapped.

    Two asks for the PR:

    1. Make sure the drains also cover the inner wait/poll loops, not just the outer iteration. The paused wait (condition.wait(until: Date(...)) every 0.5s) and the back-pressure poll around isReadyForMoreMediaData can both spin for a long time inside one outer iteration, so a pool around only the outer body would still let those accrue.
    2. Include a before/after pair of memprobe lines from your device run in the PR description. That on-device delta is the verification gate for this one.

    The music path (AudioPlaybackHost.runDemuxLoop) has the same loop shape. Feel free to include it if you want; otherwise I will sweep it in a follow-up.

  3. superuser404notfound commented on Jul 25, 2026

    @superuser404notfound
    Owner

    Released in 5.20.8. Both downstream apps are already pinned to it.

    Thanks again for the depth of this one, @nathanpiper. The memprobe pair you attached is what made it a one-pass fix instead of a guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions