[RPi400] Memory leaks?

  • Hi,

    since some time now Kodi crashes quite often (that's my feeling) apparently to out of memory.

    System: LibreELEC (official): 12.2.1, RPi 400 with 4GB.

    pan:~/.kodi/temp # dmesg | grep "Out of mem"
    [147606.130573] Out of memory: Killed process 1162 (kodi.bin) total-vm:5952300kB, anon-rss:3585432kB, file-rss:32kB, shmem-rss:0kB, UID:0 pgtables:8680kB oom_score_adj:0
    [262259.435914] Out of memory: Killed process 801006 (kodi.bin) total-vm:6259820kB, anon-rss:3539876kB, file-rss:76kB, shmem-rss:0kB, UID:0 pgtables:8844kB oom_score_adj:0
    [394588.835382] Out of memory: Killed process 1352004 (kodi.bin) total-vm:5993176kB, anon-rss:3610388kB, file-rss:48kB, shmem-rss:0kB, UID:0 pgtables:8520kB oom_score_adj:0
    [497543.605009] Out of memory: Killed process 1571503 (kodi.bin) total-vm:6066948kB, anon-rss:3544532kB, file-rss:304kB, shmem-rss:0kB, UID:0 pgtables:8428kB oom_score_adj:0

    For me nothing obvious in the kodi.log (but, I'm no expert).

    Are there any known problems with this setup?

    Before I upload tons of unnecessary logs: what's the best approach to pinpoint the problem?

    TIA,

    Oliver

  • Put Kodi in debug mode and then run "pastekodi" to share the Kodi and system log after OOM kills Kodi again. I've also seen some OOM events in recent days; albeit on an RPi5 and RK3588 device that are running my own LE13 development images which have little in-common with the LE12.2 codebase so no guarantee it's the same issue. NB: the logs aren't going to reveal the source of the problem, but will contain info on wider Kodi configuration which might be helpful.

  • The short answer is "no idea" and it's not guaranteed that what you see if the same as what I see. On my LE13 image there's 100% a bad leak, but I'm running a whole heap of experimental things that mess with DRM planes and buffers and I see the same leak on Amlogic and Rockchip (with the same patches) too. The fact nobody but you has complained before on LE12 is the main thing I find odd, as it's the kind of thing that would attract forum complaints.

    Either way, the LE13 patches need a load of reviewing and debugging and that's going to be my (Claude driven development) focus over the next week. Maybe that results in something..

  • My setup is:

    RPi 400 -> Receiver Denon AVR-X2200 -> TV LQ 65QNED86A6A --> no-name Remote (china made, bought from Amazon).

    We are using the no-name Remote instead of LG's "Magic Remote", because the latter is missing some keys (for context menus etc.).

  • I was checking whether it was a phone app remote as we suspect a leak via JSONRPC, but no.

    Memory leaks are always a bitch to find unless the impacted end-user happens to be a software developer with some experience of using debugging and analysis tools. I am also seeing a leak (or leaks) but given the differences between your LE12 and my heavily patched LE13 version of Kodi, it's unlikely to be the same root cause.

    /shrug

  • kodi.bin .. which isn't granular enough information to be useful .. and I will end up relying on others to hunt that kind of issue down as that kind of debugging isn't something I know how to do :)

  • What process seems to be leaking? Could be identified in top via ssh for instance

    I can see the increasing memory consumption of kodi quite easily:

    Top just before the crash and right after it (only the first 10 lines shown; two crash incidents):

    But of course, that doesn't help me understand what's going on inside kodi.

    Oliver

  • Hello, I'm also experiencing a nasty memory leak with LE on RPi 4B 4Gb.

    I've a similar setup as OP, where I've the RPi connected to a LG TV alongside a Denon Receiver with HDMI ARC (not sure if that's relevant, I've only just started to investigate the problem).

    I've tried setting MALLOC_ARENA_MAX=8 as mentioned in this forum but it hasn't resolved nor mitigated the problem.

  • Hi!


    In the last weeks I've tried to remove addons one-by-one to see if that helps.

    Short answer: no.

    Last thing I've tried is a fresh install of 12.2.1 (manual download, dd to new [reused] SD-Card, after first boot copying my old sources.xml and the contents of the old Database folder to the new installation).

    ==> Issue persists. After approx. 20 h of normal operation (6 h Music, 1-2 h Video playback) KODI restarts due to out-of-memory. The growing memory consumption can be easily seen through the GUI).

    I have to assume something within KODI core functionalities is causing the memory leak.

    Two questions:

    a) Could a corrupted database be the cause? I'm seeing requests at my pi-hole asking for "nas-server" where the correct name should be "nas-server.lan" (and would be answerded by my router). Sometimes in the past I changed my network config (I forgot why) and I assume this DNS requests come from KODI (I can't be sure because at the pi-hole client is always my router).

    b) when trying LE13: could I copy "sources.xml" and my Database entries? Currently I'm a bit reluctant to configure everything from scratch. If it's necessary I will do it. Right know my wife is a bit unhappy with the stability of KODI ;)

    Regards,

    Oliver