Out of memory crashes. ZRAM?

#1

Since I upgraded to Kodi 18, kodi seems to crash frequently. After a bit of hunting, most crashes are related to out of memory condition. I am not running extra processes beside openVPN (eating a couple of megabytes only). No extra addons beside a screensaver. My Raspberry Pi 3B+ has 1GB or RAM and no SWAP configured. It runs 24/7.

Apparently, Kodi (or some standard addon, I only use the standard repository) is leaking memory.

I have evolved this OSMC instance since 2015 (?), doing the monthly upgrades. Never reinstalled it again.

I wonder why nobody else is complaining about this :-?

In any case, I wonder if anybody is running OSMC on the Raspberry PI with ZRAM or similar technology. I would rather not do swap over the microSD.

Would you mind to share your Kodi memory usage after booting and after a few hours sitting idle, just for comparison?

My last Kodi instance was killed by the OOM when it was using 685MB. After 8 hours being idle (only screensaver showing a slideshow with personal pics), Kodi is using 258MB. Growing slowly. My Raspberry reports 230MB free RAM (using “free”). There is nothing else sucking memory.

Thanks for your time.

#2

Why would you use ZRAM if you don’t have any major applications eating RAM?

I never ran out of RAM on my Pi 1/2/3

#3

That is the point.

Kodi is being killed by the OOM because it is too big (almost 700 MB) after a few hours of operation. According to your reply, this is unexpected and I have something fishy in my OSMC instance. Since I don’t use any fancy addon, only a screensaver (the stock image slideshow), I wonder what is going on.

My library is quite huge, around 25.000 media files.

Since my first post, my kodi process grew from 258 to 262 MB.

#4

Ok, your original post wasn’t clear. So currently you are not using ZRAM and just was asking about it because you get OOM?

Provide debug enabled logs then we might be able to tell.

#5

The first thing I would test (besides logs as @fzinken suggested) would be to disable the screensaver.

Stats on my media library (on a PI2):

osmc@ood:~$ texturecache.py stats
Profile    : Master user
Albums     : 4141
Artists    : 5205
Songs      : 47578
Movies     : 1074
MovieSets  : 223
TVShows    : 301
Episodes   : 18613
MusicVideos: 720
Addons     : 222

So your 25,000 media files isn’t bad and should not be a problem.

And memory usage on my Pi:

  1  [||                        3.4%]   Tasks: 30, 47 thr; 2 running
  2  [|||||                    13.2%]   Load average: 0.28 0.20 0.18 
  3  [|                         0.6%]   Uptime: 8 days, 12:01:06
  4  [|                         1.9%]
  Mem[|||||||||||||||||||||281M/747M]
  Swp[                         0K/0K]

  PID USER      PRI  NI  VIRT   RES   SHR S CPU% MEM%   TIME+  Command
  530 osmc       20   0  710M  290M 56996 S 16.4 38.9 41h08:21 /usr/lib/kodi/kod
25818 osmc       20   0  4792  2244  1832 R  2.6  0.3  0:02.66 htop
 1165 osmc       21   1  710M  290M 56996 R  1.3 38.9  2h26:26 /usr/lib/kodi/kod
  586 osmc       20   0  710M  290M 56996 S  0.0 38.9 33:01.50 /usr/lib/kodi/kod
  667 osmc       20   0  710M  290M 56996 S  0.7 38.9 56:47.56 /usr/lib/kodi/kod
  587 osmc       20   0  710M  290M 56996 S  0.7 38.9 29:49.54 /usr/lib/kodi/kod
  681 osmc       21   1  710M  290M 56996 S  0.0 38.9  7:41.62 /usr/lib/kodi/kod
25558 osmc       20   0  9732  3024  2316 S  0.0  0.4  0:00.10 sshd: osmc@pts/0
  677 osmc       21   1  710M  290M 56996 S  0.0 38.9  8:37.03 /usr/lib/kodi/kod
  578 osmc       21   1  710M  290M 56996 S  0.0 38.9  2:41.91 /usr/lib/kodi/kod
  674 osmc       21   1  710M  290M 56996 S  0.7 38.9 12:47.58 /usr/lib/kodi/kod
  551 ntp        20   0  7068  2956  2516 S  0.0  0.4  2:13.25 /usr/sbin/ntpd -p
  590 osmc       20   0  710M  290M 56996 S  0.0 38.9  1:09.77 /usr/lib/kodi/kod
  676 osmc       21   1  710M  290M 56996 S  0.0 38.9  9:51.54 /usr/lib/kodi/kod
#6

Ok, Sorry. No, I am not using ZRAM. Just thinking about that.

I am disabling the screensaver, enabling debug logging and rebooting my raspberry pi. Now, lets wait for a few hours before posting logs.

Currently, my KODI is using 220MB. Let’s see.

Thanks

#7

What command are you using? I guess your multiple KODI entries are different threads for the same process.

htop, I guess. Not installed here. I am checking memory usage with “ps” and “vmstat” :).

#8

htop. To install it:

sudo apt install htop

Correct.

#9

You could also use inxi (a command line-system information script)
To install inxi connect using SSH with your RPI

sudo apt-get install inxi

inxi options

#10

I have a Raspberry Pi 3 Model B Rev 1.2 according to dmesg.
It is running OSMC w/ Kodi v18. The package according to dpkg is
rbp2-mediacenter-osmc 18.3.0-11
I runs 24/7 and I can’t remember the last time it crashed.
No swap here according to free
$ free -mh
total used free shared buff/cache available
Mem: 730M 193M 74M 14M 462M 475M
Swap: 0B 0B 0B
I don’t remember the skin, but it isn’t the default. I miss Confluence which worked great before v18. The OSD stuff is really obnoxious and the caching of media files from DLNA sources has been a problem recently.
For a VPN, I have an Ubuntu VM running under KVM, but generally use ssh, ssh-proxy or x2go into my normal desktop when I’m travelling. The r-pis in the house aren’t used for that.
I’ve setup zram on other laptops before and it did help, but on a Pi, I wouldn’t want to destroy the microSD cards nearly that fast. I’ve never had a microSD fail due to write endurance issues in a Pi, but there is a 32G flash card in it with only about 16G used.
I don’t have a screen saver enabled either. It is a media player connected to a projector and receiver for audio and nothing more. Besides OSMC, sometimes I’ll use cmus to playback audio when the projector isn’t on.

Anyway, it is stable. I haven’t done a full re-install in years. Just do a dist-upgrade every 6 months or so when the timing won’t get me into trouble with the wife, she who must be obeyed. :wink:
With my lazy patching, I wouldn’t want it available to the internet. I’ve been running internet servers for over 25 yrs now.

#11

Confluence can still be had.