[x86-64] kodi.bin steady memory leak ~40 MB/hour leading to system freeze (kswapd spin, 100% kernel CPU)

  • Environment: LibreELEC 12.2.1, Kodi 21.3.0 Omega, Intel Celeron J3355, 7.3 GB RAM, no swap (by default)


    Problem: steady memory leak ~46 MB/hour, leads to full freeze after ~1.5-2 days

    kodi.bin RSS increases at ~2 MB per 3 minutes while completely idle on the home screen. After ~58 hours it reaches ~2 GB, kswapd0 spins at 72% CPU, load average hits 32, 99.6% kernel time. SSH port is open and ping works, but sshd is not scheduled — userspace is frozen. Docker (qBittorrent) on the same host keeps running.

    Measurement example (uptime ~2h46m at start): 20:00 — 400 MB 20:03 — 402 MB (+2) 20:06 — 404 MB (+2) 20:09 — 405 MB (+1) 20:12 — 407 MB (+2) 20:19 — 411 MB (+4) Fresh after reboot (12 min uptime): 270 MB. After 3 hours: 411 MB (+141 MB). Rate: ~46 MB/hour.

    Ruled out:

    • Library auto-update: disabled (videolibrary.updateonstartup=false, backgroundupdate=false, same for music)
    • Thumbnails dir: 34.5 MB, stable
    • No library scan events in kodi.log during idle periods
    • advancedsettings.xml: not configured (default values)
    • Cache settings: all default in guisettings.xml

    Log pattern during leak: Repeated entries of two types: "OutputPicture - timeout waiting for buffer" "Loading skin file: DialogFullScreenInfo.xml, load type: KEEP_IN_MEMORY"

    These appear consistently throughout the period of increasing RSS.

    Workaround:

    1. Added 16 GB swapfile on /storage — prevents hard freeze, system degrades gracefully
    2. Daily "systemctl restart kodi" via cron at 04:00 — stops accumulation

    Questions:

    1. Is the KEEP_IN_MEMORY + OutputPicture timeout pattern a known issue in 21.3.0?
    2. Are there any advancedsettings.xml knobs that can bound GUI texture memory? Specifically interested in imageres / fanartres to reduce texture size in RAM — the wiki mentions these still work in v21 for artwork cache resolution, even though video buffer cache settings have moved to Settings > Services > Caching (GUI only since Omega).
    3. Has anyone seen this specific pattern (idle leak, no playback, no library scans, skin file loads repeating) and identified the root cause? The LibreELEC forum thread on LE12 nightlies mentioned similar idle leaks tied to specific addons (YouTube, pvr.hts) — but I have none of those installed.

    Addons installed: metadata scrapers (tmdb, tvdb, fanart.tv), script.module.pil, script.module.pycryptodome, service.system.docker, game.controller.snes.

  • Go test this image https://chewitt.libreelec.tv/testing/LibreE…-12.90.1.img.gz and report back. Note that this image is LE13 and we switched Generic from OpenGL back to OpenGLES so if you have screensaver and visualisation add-on installed those will need to be removed, the cache in /storage/.kodi/addons/cache deleted, and then the add-on needs to be reinstalled else things will crash. Just leave settings present and it's no big deal.

    NB: I'm not answering the Q's above as there are known rendering bugs solved and notable changes to rendering in this image; and the combination means triaging anything on LE12.2 isn't a productive use of time (there are no plans for a 12.3 release).