Over time we found some memory fragmentation issues that affect long-uptime systems. Check free RAM, and if that's the issue, start planning an update to 9.0 as that's when it'll be resolved.
OK, that seems very plausible since it typically takes several months for a problem to develop, and my script runs every 12 minutes. I thought the same as I have similar problem with my router, also in about 90 days time. But, for now, I want to resolve it on the current version. I dislike upgrades if I I do not have clear reasons.
What to monitor? I am perfectly happy to monitor something and reboot if it gets over certain amount.
Largest memory spent and only above 1mb are:
top
Mem: 270904K used, 483752K free,
527m 71.3 0 0.8 /usr/lib/kodi/kodi.bin --standalon
287m 38.8 1 0.0 {tvheadend} /storage/.kodi/addons/
ps does not show me memory, but I could use top like this:
top -n1 | grep kodi.b[i]n
top -n1 | grep tvheade[n]d
or is it better to monitor just the free memory, so if it drops below something, reboot.
top -n1 | grep fre[e] | cut -d" " -f4
or probably better:
mem_free=$(( $( free | awk 'NR==2 {print $4}' ) / 1024 )); echo $mem_free
What should I set for a reboot limit? 100kb? Or is this not a good tactics to capture this problem?
Or simply do a preemptive RPi reboot say once monthly. But, I would prefer to know exactly why I am doing it than to simply reboot without learning anything.