#29262·xbmc

Continuous native memory leak during video playback on Android (regression: 22.0-BETA1 → BETA2), eventually freezes playback

Author: beeeeswaxCreated Sep 10, 2026Updated Sep 14, 2026
LabelsPlatform: AndroidTriage: Needed

Bug report

Describe the bug

Since upgrading from 22.0-BETA1 to 22.0-BETA2 on Nvidia Shield 2019 Pro (Android TV), video playback develops a continuous native memory leak that grows at a steady, near-linear rate throughout playback, eventually exhausting available system memory and freezing playback.

  • Leak rate is consistently ~18-20MB/min in 'Native Heap' (Private Dirty), measured via 'dumpsys meminfo' across two separate full sessions.
  • The rate does not accelerate over time, is not tied to any single event (seeking, pausing, subtitle load), and survives across file/episode boundaries within the same Kodi process - it is continuous for as long as playback (or the app) runs.
  • Growth is independent of 'EGL mtrack' / 'Graphics' memory, which stayed flat throughout (~50MB, unchanged even as Native Heap climbed past 1.5GB) - this rules out a leaked MediaCodec output surface/EGL buffer as the cause and points at a native heap (malloc/new-side) leak instead.
  • MediaCodec's own input/output buffer counts ('AddData' vs 'ReleaseOutputBuffer') stayed balanced during normal playback, so the leak does not appear to be simply undropped decode buffers either.
  • Eventually (once free memory drops to roughly 150-200MB of the 3GB available on the Shield), the device runs out of headroom, starts swapping, and playback and system responsiveness collapse (see Actual Behavior below).
  • Fully resolved only by force-stopping and relaunching the app - stopping playback alone does not release all the leaked memory (see numbers below), suggesting whatever is leaking outlives the playback session/'CloseFile()'.

Expected Behavior

Native heap memory usage should remain roughly stable during continuous playback, not climb without bound.

Actual Behavior

Full reproduction, unpaused, with debug log + 'dumpsys meminfo' captures at each stage:

Elapsed Free RAM Native Heap (Private Dirty) Notes
0 min (launch) ~1.2GB 485MB Baseline after startup settles
~21 min ~750MB 897MB Steady climb, ~18-20MB/min
~38 min 470MB 1182MB
~53 min 285MB 1467MB First stuttering reported
~60 min 180MB 1573MB Stuttering worsening
~61 min 170MB 1523MB Full freeze (see timeline below)
~61.3 min 315MB 1454MB After forced stop - only partial recovery (vs. 1.2GB baseline)

Timeline of the freeze itself, taken directly from the debug log (all times same session, no pause/seek preceding any of this):

  • 00:46:06 - First 'OutputPicture - timeout waiting for buffer' warning. Repeats and escalates in frequency over the next ~43 seconds.
  • 00:46:48 - A 'dumpsys meminfo' call against the Kodi process itself timed out: '*** SERVICE 'meminfo' DUMP TIMEOUT (10000ms) EXPIRED ***'. Android's own diagnostic service could not get a response from the process within 10 seconds - this is genuine system-level starvation, not just a UI/render hang. 'adb' itself became sluggish/unresponsive around this point too.
  • 00:46:49 - Kodi's own stall detection correctly fires: 'stream stalled, triggering re-sync' → 'FlushBuffers' → 'CDVDVideoCodecAndroidMediaCodec::Reset'. 'SwapPss' in the meantime jumped from single-digit KB (for the entire first ~50 minutes) to 20-25MB - the device started swapping under the memory pressure.
  • 00:46:58 - Video recovers briefly ('GetPicture VC_BUFFER', "Stillframe left, switching to normal playback") after the codec reset and a demux re-seek.
  • 00:47:01 onward - The recovery doesn't hold: the audio renderer starts timing out too ('CDVDAudio::AddPacketsRenderer - timeout adding data to renderer', repeating every few seconds), confirming this is whole-pipeline starvation rather than a video-decoder-specific issue.
  • 00:47:07 - First JSON-RPC 'Stop' request (sent via a remote app) is received by the webserver.
  • 00:47:26.6 - 'CVideoPlayer::CloseFile()' finally executes - ~19-20 seconds after the stop request arrived, matching the "10-20s to respond to a stop request" symptom.

Possible Fix

The FFmpeg version bumped from 8.1.2 (beta 1) to 9.0.1 (beta 2) in this release, which is by far the largest change to the video pipeline between the two builds - flagging this as the most likely area to start looking, though I have not been able to bisect further myself.

I checked two other upstream changes merged since BETA2 and ruled them out, since neither applies to this content: the PGS-subtitle colorimetry fix (I'm using SRT, not PGS) and the AV1 pixel-format fix (this is H.264, not AV1). Mentioning them only so anyone triaging doesn't have to re-check the same dead ends.

To Reproduce

Steps to reproduce the behavior:

  1. Nvidia Shield 2019 Pro, Android TV 9, Kodi 22.0-BETA2.
  2. Play a local-network (SMB) 1080p H.264 file with DD+ 5.1 audio passed through to an AVR, with an external SRT subtitle enabled.
  3. Let playback run continuously (tested across ~60-70 minutes and two back-to-back episodes with no app restart).
  4. Monitor 'adb shell dumpsys meminfo ' over time - 'Native Heap' (Private Dirty) climbs steadily at ~18-20MB/min with no plateau.
  5. Eventually (timing depends on available RAM) playback stutters, then freezes; the app becomes unresponsive to remote/JSON-RPC commands for 10-20+ seconds.

Not reproducible on 22.0-BETA1 under the same conditions (per my own prior usage - I have not re-tested BETA1 specifically for this report, but the symptom began immediately after the BETA1→BETA2 upgrade).

Debuglog

The debuglog can be found here:

PixelDrain

Contains the full debug log (with 'ffmpeg' library logging and video-component verbose logging enabled) covering the entire session from Kodi launch through to the freeze, plus the corresponding 'dumpsys meminfo' captures taken at each labeled memory milestone (timestamps/free-RAM in the filenames). Hosted myself (rather than the official log uploader) so I can control retention - happy to re-upload or provide additional captures if the link expires before someone gets to this.

Screenshots

N/A - see debug log and memory captures linked above.

Additional context or screenshots (if appropriate)

  • FFmpeg version: '9.0.1-Kodi'
  • Playback: H.264 / DD+5.1 (passthrough) / SRT, MKV container, played from SMB share

Your Environment

Used Operating system:

  • Android

  • iOS

  • tvOS

  • Linux

  • macOS

  • Windows

  • Windows UWP

  • Operating system version/name: Android TV 9.0.0, API level 28, kernel 4.9.140-tegra (NVIDIA SHIELD Android TV, 2019 Pro)

  • Kodi version: 22.0-BETA2 (21.90.802) Git:20260831-e513e0ff43