matthuisman / slyguy.addons

Github mirror of SlyGuy add-ons
https://www.matthuisman.nz/2020/02/slyguy-kodi-repository.html
279 stars 77 forks source link

Memory leak in update checker #628

Closed Didero closed 9 months ago

Didero commented 9 months ago

I'm running Kodi through OSMC on a Raspberry Pi 3, and I've noticed the memory usage slowly creeping up, with about 0.1 to 0.3% more RAM usage every hour. It's not much, but the RPi 3 also doesn't have a lot of RAM, so after a week or two, memory is too full and video playback starts to suffer. Through a process of elimination I've determined that the memory leak is from the SlyGuy Common addon, since when I disabled that addon, the memory leak didn't occur even after letting OSMC run idle for a day. To further pinpoint the cause, I played around with the settings of the addon, and when I changed the 'HTTP Retries' setting in the 'Advanced' tab from 1 to 0 and letting OSMC run idle for most of a day, the memory leak was also gone. When I changed that setting to 10, the hourly memory increase got larger. During all my testing, I didn't do anything else with the Raspberry Pi besides logging in through SSH to check RAM usage occasionally. So my conclusion is that there is some sort of memory leak in the update code relating to retries. Could you please look into it? Thanks in advance. Finally, thanks for all your work, we can now watch Disney+ on our old app-less TV, and my mom loves it!

matthuisman commented 9 months ago

thanks for raising this issue.

Do you have a debug log? I want to see why increasing the retries affects it. I assume one of the urls is failing?

Didero commented 9 months ago

Sorry, I should've included a log in the first place. I've attached the debug log, after it's been running overnight: kodi.log

matthuisman commented 9 months ago

ok. so i cant see any retries so its odd that more retries leads to higher usage.

Anyway, ill try find a way to record the mem usage so i can try removing different bits of code and see what stops it :) Ive seen a few bugs about requests not closing sessions correctly. so maybe something like that

Didero commented 9 months ago

Thanks for looking into it! Sorry my log wasn't more helpful. If there's anything more I can do to help pinpoint the problem, let me know.

matthuisman commented 9 months ago

@Didero the memory leak should be fixed with script.module.slyguy -> v0.75.4

I really appreciate you bringing this to my attention and finally getting it sorted :)

Please report back on how it goes for you!

Didero commented 9 months ago

The memory usage of Kodi on my Raspberry Pi doesn't slowly go up anymore, so the leak seems fixed. Thanks for looking into this and for finding a solution!