kodi.bin process using more memory day after day

  • Hello guys!


    When I turn on my Raspberry Pi the kodi.bin process use something like 16% of memory (without playing anything). Pass some time this process increase more memory.
    Today, 4 days after I turn it on, kodi.bin are using 31.4% of memory. In this way with more 3 or 4 days my Raspberry will freeze because have no memory available.

    My question is: this is normal? I'm talking about the memory usage without playing anything. There's a way I can get around this?


    My logs bellow (but without debug enabled).

    Kodi.log: http://ix.io/1fih

    System.log: http://ix.io/1fij


    Thanks!

  • Same problem with NUC7i5bnk with 8g of memory, never gets to 4g before crashing.


    I know there's a answer for this...

  • For what it's worth I'm adding my report to this issue. I haven't yet found a definitive root cause/effect, despite it being an apparent issue since upgrading to Leia.


    I first noticed it when Kodi crashed out hard, mangling various .xml config files that were being accessed at the time, giving rise to all sorts of weirdness upon reboot. Ended up having to do a restore of kodi settings from backup.


    Subsequent investigation showed an ever increasing amount of memory use over time that never gets freed up. My usage pattern of sleep/resume to activate/deactivate the machine as required, instead of doing a hard power-down/cold-boot, means I'm effectively running one very long Kodi uptime session just split up over many `powered-on` time periods so the ongoing memory leak behaviour becomes very apparent.


    I've been poking around here and Kodi main forum off and on again fairly regularly looking for things that might be relevant, but no silver bullets yet.

    I can reproduce the issue quickly by hammering on the Youtube & Twitch.tv plugins - skipping around constantly and causing chunks of streamed video data to be loaded/reloaded into memory in an erratic pattern and seemingly never cleaned up once no longer required. It's not a 1:1 relationship between bytesize of video download and memory consumed, so I'm not sure exactly what data it is that's kept hanging around in RAM.


    The common denominator between the two plugins is inputstream.adaptive so I thought I'd found a smoking gun, but sadly not since the problem also happens with `regular` video viewing ... just at a slower rate of memory leakage.

    Under the hood the `web streaming` plugins operate by effectively playing lots of small individual downloaded chunks of, say, mp4 video consecutively to give the appearance of playing one large monolithic local mp4 file. e.g one "1GB total" stream stream really consists of 250 4MB videos strung together.

    However - you can also provoke memory leakage by stopping and starting lots of locally stored video - tested by scripting the stop/start playing/jumping/seeking of a several hundred single mp4/mkv/ts files from my local hard disk and NAS sources. Lo and behold the memory leak exhibited itself again, albeit at a much slower rate of accumulation.


    Unfortunately I'm pretty stuck now, because this kind of behind the scenes memory allocation/garbage-cleanup doesn't show up in Kod logs (even at debug level) - you'd need to attach the processes to a proper debugger environment to diagnose effectively, which is way beyond my level of competence :(


    Hardware: Zotac MiniPC with Intel Core i3-3227U CPU, Nvidia GT640 GPU, 4GB RAM.

    Software: LibreELEC 9.0.1 / Kodi 18.1 (Leia)

  • kurai

    Just sharing what I noticed after post this.

    I use kodi as you

    My usage pattern of sleep/resume to activate/deactivate the machine as required, instead of doing a hard power-down/cold-boot, means I'm effectively running one very long Kodi uptime session just split up over many `powered-on` time periods

    but, some times I restart it, because I new thing I installed to test or something like that, and in some sessions this bug don't shows!

    I tried reproduce the bug with youtube add-on, like you said, and not happend! It used 2% of more memory when I watched a trailer, but after released!

    It's hard detect the cause of this! :/

    Supercalifragilisticexpialidocious! (inscribed in large friendly letters)

    My hardware is a Raspberry Pi 3b

  • Quote

    kodi.bin process use something like 16% of memory (without playing anything). Pass some time this process increase more memory.

    Same here. At first I thought it is a memory fragmentation issue but it looks more like a memory leak in Kodi.

    I reported about this on Kodi github here.

  • I think what's causing this bug is library update. I updated the library and noticed a little memory incrementation, but not released.

    Guys, check if this happened with you too. Do library update several times and check memory usage. Remove some movie/tv show, do library update and check memory usage again.


    For the record I'm using Universal Movie Scrape for movie informations.

    Supercalifragilisticexpialidocious! (inscribed in large friendly letters)

    My hardware is a Raspberry Pi 3b

  • I don't use any scrapers ever. For me kodi.bin RAM usage increase at around 1% per hour when playing a high bitrate full HD video. And it's even worse when playing a 4K video.

  • I kinda solved this by enabling swap memory.

    I know this is not a solution, is more like an workaround, but is working for me!

    There's a [How to] here explaining how to enable.

    Supercalifragilisticexpialidocious! (inscribed in large friendly letters)

    My hardware is a Raspberry Pi 3b

  • Yeah - I've done similar ... cannibalized a 2nd 4GB RAM module from an old laptop that I almost never use, plus enabled an 8GB swapfile too.


    It's totally not addressing the real problem, but until someone solves the issue at least there's 16GB of total space for the system to thrash around in. Should take it a fair while longer before it reaches the Out Of Memory crash-and-burn phase ... hopefully enough so that I have a reasonable chance of noticing when it's getting towards the danger zone and rebooting before it all goes flop. /shrug

  • I've tried using a 4GB swapfile. I tried 8GB but it would not allow it.

    When the memory usage gets to around 4GB, then swapfile kicks ( using "top" to read memory ).


    I have never seen "kodi.bin" get over 4gb before it cashes.


    Now I restart kodi when it gets close to 4gb and stopped using a swapfile.


    Like I mentioned before.. there is a fix, just waiting for one


    I have two NUC's ( nuc7i5bnk, nuc6cayh ) with same issue

  • Would not be easier to restart Kodi at 3AM every night? It is not a fix but still :)


    Support my work with small (or big) Paypal donation


    Amlogic devices works better with CoreELEC

    Blu-ray Disc Java menus support - forum thread, Github

    my lamp addon (unofficial/community with limited support)
    my touchscreen support and instructions by Grruhn (now touchscreen addon exists in repository)


  • Would not be easier to restart Kodi at 3AM every night? It is not a fix but still :)

    Probably so, but where's the fun in that? ^^


    I now have a kind of morbid curiosity to see just how much kodi.bin can grow the heap before it all collapses.