Allocated memory growing every day in 8.95.0

My Tanix TX7 905X box is running version 8.95.0 for some time now, very good and stable release. Thanks guys.
The box is usually always on playing .flac music and movies during the day so it’s opening many audio/video files.
I was checking the temperature in the settings because it seems to rise in these hot summer days, but CPU load was OK.
Surprise for me was that after 5 days of uptime the memory usage was at 1.2 GB.
After restart the allocated memory dropped to 230 MB but is slowly rising every day.
Not a big issue but I don’t like the idea of restarting every 5-6 days.

I’m not sure but I don’t remember this behavior on older versions I used (CE 8.90.2, LE 8.90.2).
It’s just my configuration or anyone with similar experience?
Thanks

If you don’t have any issues you don’t need to reboot it. It can free some memory later, check bigger interval

When you SSH into your box, run the top utility and see if those compounded RAM usage is allocated in buffer. If so, then I reckon you don’t need to worry. You can clear some of caches in the buffer by sending an echo 3 > /proc/sys/vm/drop_caches from your CLI while SSH into your box, instead of rebooting your box. I have the following simple shell script under ~root/local/bin/clrcaches and use it to clear some caches in the buffer. Make sure you don’t forget to add ~/local/bin to your $PATH.

#!/bin/sh
sync ; swapoff -av ; swapon -av ; echo 3 > /proc/sys/vm/drop_caches ; top

Thanks for your information. I have checked the memory info in top command and executed your suggested command to clear buffer(which saved about 100MB of cache).
After 3 days uptime the result is still not very positive:
KiB Mem : 1833352 total, 521072 free, 1101320 used, 210960 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 524836 avail Mem

After buffers cleanup the box is reporting is 1.1GB used memory of total 1.8GB. 200MB is buffer/cache and 500MB is free. Seems that every day I loose approx. 250MB of free memory.

Not sure what exactly did you mean by After 3 days uptime the result is still not very positive.

My CE Box runs ONLY stock applications, i.e. kodi, etc. If you had installed and/or enabled additional applications to run on your kodi box, perhaps you can start out with a fresh CE installation to narrow down which application causes the problem. Otherwise, my suspect is probably some kodi plugins leak out memory. In this case, you can start kodi with a fresh configuration to find out if it still does leak the memory. If it doesn’t, then proceed to add more plugin one at a time and observe the memory usage.

1 Like

I use a very low memory device rather intensively 24/7 . Memory never grows above 50-60% utilization.

Did you ever have a crash or is restarting every 5-6 days just a precaution?

I really wouldn’t worry about it.
If you really want to know what’s eating heaps of memory you could start with a minimal setup and gradually add your add-ons so you can narrow it down.

It didn’t crashed, but after 3-5 days it seems to start lagging response to remote commands.
I have maybe 20 different plugins installed but use just a few of them daily, will try to identify whether it’s related to one of them.
I was curious whether the problem is experienced by other users and related to version 8.95.0.

Not in my case, but I use very few addons

When this happens, try the top utility once you have SSH into your TV Box and see what happens, i.e. which applications eat up how much % of CPU resources, etc.

I don’t know if this will do any good or not. However, I have installed both TVAddons and LihatTV plugins on my CE TV Box. After finishing with the configuration as I wanted, the list on my ~/.kodi/addons is shown below. Looks like lots of plugins have been enabled, yet the RAM usage is around 250 MB on idle.

CoreELEC:~ # ls -la .kodi-20180814/addons/
total 412
drwxr-xr-x  103 root     root          4096 Aug 14 11:51 .
drwxr-xr-x    7 root     root          4096 Dec 31  2014 ..
drwxr-xr-x    3 root     root          4096 Aug 14 11:19 game.controller.default
drwxr-xr-x    3 root     root          4096 Jul 13 16:04 imagedecoder.raw
drwxr-xr-x    3 root     root          4096 Jul 17 02:27 inputstream.adaptive
drwxr-xr-x    3 root     root          4096 Jul 13 16:04 inputstream.rtmp
drwxr-xr-x    3 root     root          4096 Aug 14 11:20 metadata.album.universal
drwxr-xr-x    3 root     root          4096 Jul 26 20:41 metadata.artists.universal
drwxr-xr-x    2 root     root          4096 Aug 14 11:50 metadata.common.allmusic.com
drwxr-xr-x    2 root     root          4096 Aug 14 11:50 metadata.common.fanart.tv
drwxr-xr-x    2 root     root          4096 Aug 14 11:20 metadata.common.imdb.com
drwxr-xr-x    2 root     root          4096 Aug 14 11:51 metadata.common.musicbrainz.org
drwxr-xr-x    2 root     root          4096 Aug 14 11:51 metadata.common.theaudiodb.com
drwxr-xr-x    2 root     root          4096 Aug 14 11:19 metadata.common.themoviedb.org
drwxr-xr-x    3 root     root          4096 Jan 29  2018 metadata.doubantv.com
drwxr-xr-x    3 root     root          4096 May  8 22:36 metadata.themoviedb.org
drwxr-xr-x    3 root     root          4096 Jul 19 02:28 metadata.tvdb.com
drwxr-xr-x    2 root     root          4096 Aug 14 11:51 packages
drwxr-xr-x    3 root     root          4096 Jul 13 16:04 peripheral.joystick
drwxr-xr-x    3 root     root          4096 Jan 29  2018 plugin.audio.radio_de
drwxr-xr-x    3 root     root          4096 Jan 29  2018 plugin.audio.radioreference
drwxr-xr-x    3 root     root          4096 Jan 29  2018 plugin.audio.soundcloud
drwxr-xr-x    4 root     root          4096 Jul 13 16:06 plugin.git.browser
drwxr-xr-x    7 root     root          4096 Aug 14 11:56 plugin.program.indigo
drwxr-xr-x    3 root     root          4096 Jan 29  2018 plugin.video.DecadoDocs
drwxr-xr-x    3 root     root          4096 Apr  8 20:56 plugin.video.LiveTube
drwxr-xr-x    2 root     root          4096 Jan 29  2018 plugin.video.asia-tv
drwxr-xr-x    3 root     root          4096 Apr  8 20:56 plugin.video.bhg.uktvplay
drwxr-xr-x    3 root     root          4096 Jan 29  2018 plugin.video.cntv-live
drwxr-xr-x    3 root     root          4096 Feb  8  2018 plugin.video.covenant
drwxr-xr-x    4 root     root          4096 Jan 29  2018 plugin.video.earthcam
drwxr-xr-x    4 root     root          4096 Aug 14 11:20 plugin.video.eyny
drwxr-xr-x    3 root     root          4096 Feb  8  2018 plugin.video.f4mTester
drwxr-xr-x    3 root     root          4096 Jan 29  2018 plugin.video.filmon.simple
drwxr-xr-x    4 root     root          4096 Aug 14 11:20 plugin.video.iplayerwww
drwxr-xr-x    3 root     root          4096 Jan 29  2018 plugin.video.itunes_podcasts
drwxr-xr-x    3 root     root          4096 Jan 29  2018 plugin.video.lihattv
drwxr-xr-x    7 root     root          4096 Feb  8  2018 plugin.video.live.streamspro
drwxr-xr-x    3 root     root          4096 Aug 14 11:19 plugin.video.newson
drwxr-xr-x    3 root     root          4096 May 22 12:29 plugin.video.newsy.tva
drwxr-xr-x    3 root     root          4096 Apr 30 22:50 plugin.video.plutotv
drwxr-xr-x    3 root     root          4096 Jan 29  2018 plugin.video.rrmj
drwxr-xr-x    3 root     root          4096 Feb 11  2018 plugin.video.sugoideasV2
drwxr-xr-x    3 root     root          4096 Jul 13 17:12 plugin.video.tvplayer.com
drwxr-xr-x    3 root     root          4096 Aug 14 11:19 plugin.video.ustv.catchup
drwxr-xr-x    3 root     root          4096 Feb  2  2018 plugin.video.ustvnow.tva
drwxr-xr-x    3 root     root          4096 Jan 29  2018 plugin.video.vice
drwxr-xr-x    3 root     root          4096 Jan 29  2018 plugin.video.yinyuetai
drwxr-xr-x    3 root     root          4096 May 27 12:29 plugin.video.youtube
drwxr-xr-x    2 root     root          4096 Jan 29  2018 repository.BludhavenGrayson
drwxr-xr-x    2 root     root          4096 Feb  8  2018 repository.colossus
drwxr-xr-x    2 root     root          4096 Jan 29  2018 repository.japanese
drwxr-xr-x    3 root     root          4096 May 17 12:29 repository.kodinerds
drwxr-xr-x    2 root     root          4096 Jan 29  2018 repository.lydian
drwxr-xr-x    2 root     root          4096 Jan 29  2018 repository.xbmc-addons-chinese
drwxr-xr-x    2 root     root          4096 Jan 29  2018 repository.xbmchub
drwxr-xr-x    4 root     root          4096 Jan 29  2018 script.common.plugin.cache
drwxr-xr-x    4 root     root          4096 Feb  8  2018 script.covenant.artwork
drwxr-xr-x    4 root     root          4096 Feb  8  2018 script.covenant.metadata
drwxr-xr-x    3 root     root          4096 Jan 29  2018 script.module.addon.common
drwxr-xr-x    3 root     root          4096 Mar 16 01:30 script.module.addon.signals
drwxr-xr-x    3 root     root          4096 Jan 29  2018 script.module.beautifulsoup
drwxr-xr-x    3 root     root          4096 Jan 29  2018 script.module.beautifulsoup4
drwxr-xr-x    3 root     root          4096 Jan 29  2018 script.module.certifi
drwxr-xr-x    3 root     root          4096 Jan 29  2018 script.module.chardet
drwxr-xr-x    4 root     root          4096 Jul 13 16:04 script.module.commoncore
drwxr-xr-x    3 root     root          4096 Feb  8  2018 script.module.covenant
drwxr-xr-x    3 root     root          4096 Jan 29  2018 script.module.feedparser
drwxr-xr-x    3 root     root          4096 Jul 14 02:30 script.module.future
drwxr-xr-x    3 root     root          4096 Jan 29  2018 script.module.googleapi
drwxr-xr-x    3 root     root          4096 Jan 29  2018 script.module.html5lib
drwxr-xr-x    3 root     root          4096 Mar  7 00:40 script.module.httplib2
drwxr-xr-x    3 root     root          4096 Jan 29  2018 script.module.idna
drwxr-xr-x    5 root     root          4096 Jan 29  2018 script.module.liveresolver
drwxr-xr-x    4 root     root          4096 Feb  8  2018 script.module.metahandler
drwxr-xr-x    3 root     root          4096 Feb  8  2018 script.module.myconnpy
drwxr-xr-x    3 root     root          4096 Jan 29  2018 script.module.oauth2client
drwxr-xr-x    3 root     root          4096 Feb  8  2018 script.module.parsedom
drwxr-xr-x    3 root     root          4096 Apr 21 00:40 script.module.pyhdhr
drwxr-xr-x    3 root     root          4096 May 17 12:29 script.module.requests
drwxr-xr-x    4 root     root          4096 Feb  8  2018 script.module.simple.downloader
drwxr-xr-x    3 root     root          4096 Jan 29  2018 script.module.simplecache
drwxr-xr-x    3 root     root          4096 Jan 29  2018 script.module.simplejson
drwxr-xr-x    3 root     root          4096 Jan 29  2018 script.module.six
drwxr-xr-x    3 root     root          4096 Jan 29  2018 script.module.t0mm0.common
drwxr-xr-x    3 root     root          4096 May 12 22:39 script.module.uepg
drwxr-xr-x    3 root     root          4096 Jan 29  2018 script.module.uritemplate
drwxr-xr-x    3 root     root          4096 Jan 29  2018 script.module.urllib3
drwxr-xr-x    4 root     root          4096 Aug 14 11:19 script.module.urlresolver
drwxr-xr-x    3 root     root          4096 Jan 29  2018 script.module.xbmcswift2
drwxr-xr-x    3 root     root          4096 Jan 29  2018 script.module.yaml
drwxr-xr-x    4 root     root          4096 Apr 30 22:50 script.module.youtube.dl
drwxr-xr-x    3 root     root          4096 Jul 13 16:04 script.program.driverselect
drwxr-xr-x    3 root     root          4096 Jan 29  2018 script.tv-icon.jp
drwxr-xr-x    4 root     root          4096 Jan 29  2018 script.tvaddons.debug.log
drwxr-xr-x    3 root     root          4096 Feb  6  2018 script.ustvnow.plus.guide
drwxr-xr-x    3 root     root          4096 Feb  8  2018 script.video.F4mProxy
drwxr-xr-x    2 root     root          4096 Jul 26 20:40 service.subtitles.zimushe
drwxr-xr-x    2 root     root          4096 Mar  7 00:40 service.subtitles.zimuzu
drwxr-xr-x   10 root     root          4096 Aug 14 11:51 temp
drwxr-xr-x    3 root     root          4096 Jul 16 02:27 vfs.rar
drwxr-xr-x    3 root     root          4096 Jul 14 02:31 weather.gismeteo
drwxr-xr-x    3 root     root          4096 Jan 29  2018 weather.yahoo
CoreELEC:~ # top

top - 09:05:51 up  8:43,  1 user,  load average: 2.40, 2.42, 2.41
Tasks: 121 total,   2 running, 119 sleeping,   0 stopped,   0 zombie
%Cpu0  :  0.0 us,  1.4 sy,  0.0 ni, 98.6 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu1  :  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu2  :  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu3  :  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu4  :  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu5  :  4.8 us,  0.0 sy,  0.0 ni, 95.2 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu6  :  2.1 us,  0.0 sy,  0.0 ni, 97.9 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu7  :  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  1785024 total,  1012028 free,   253024 used,   519972 buff/cache
KiB Swap:        0 total,        0 free,        0 used.  1309760 avail Mem 

PID USER    PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                       
2803 root   20   0  642644 211524  59916 S   8.3 11.8  67:18.44 kodi.bin                                                      
3407 root   20   0    2716    936    732 R   1.4  0.1   0:00.06 top                                                           
1 root      20   0   24384   3628   2736 S   0.0  0.2   0:04.35 systemd                                                       
2 root      20   0       0      0      0 S   0.0  0.0   0:00.02 kthreadd                                                      
3 root      20   0       0      0      0 S   0.0  0.0   0:18.76 ksoftirqd/0                                                   
5 root      0  -20       0      0      0 S   0.0  0.0   0:00.16 kworker/0:0H                                                  
7 root      20   0       0      0      0 S   0.0  0.0   0:05.25 rcu_sched                                                     
CoreELEC:~ #

TBH, I don’t know about others, but my folks have been using the CE box to stream Formosa TV (Video-on-Demand) from YouTUBE and so far no problems at all. With the system on idle only uses about 1/8 of 2 GB RAM, I reckon it is safe to say CE 8.95.0 is pretty stable so far.

Please do let us know if you manage to locate the culprit.

I have made a fresh new install of latest 8.95.1 version, installed all my basic add-ins and continued testing.
The bad news is the problem repeats itself, memory usage is growing quite fast upto 1000MB in 3 days of usage.
Good news is that I have a clue now, seems that playing FLAC music files from USB flashdisk in a loop is causing the extreme memory usage. Playing videos is OK.
My audio settings are following:
Audio device is ALSA default, PCM, 2 channels, output BEST MATCH, resample quality HIGH.
I usually play a few FLAC albums in a continuous loop. After 1 day > 500MBmemory allocated, after 2 days 800MB,…

I had hopes that the amlogic-ng kernel based CE could improved this old problem.
Used last nightly build of CE and … the problem still persists.
After 2 days of .flac music playback (from usb flashdrive) a lot of system memory is allocated. After clearing the buffers a small part (about 50MB) is released but the rest remains allocated. Please see the screens below:


memory_after_2_days_of_flac_music top_after_2_days_of_flac_music
Could anyone please look into why KODI process is eating memory during .flac music playback?

This could be the glibc memory fragmentation.
Try adding

MALLOC_ARENA_MAX=1

to /storage/config/kodi.conf.

Yes, I have seen this in my Gt King box too… slow memory leaks…

Thanx, will test.
The location on my CE box was /run/libreelec/kodi.conf, but it seems this configfile is reset to default after each Kodi restart… Not sure which config file to modify so manual changes survive Kodi restart.

I found 3 different kodi.conf files on my CE installation, listed below.
The first file in the list is generated everytime kodi starts so I can’t put any changes into it.
The other files seem to have different purpose.
Could anyone help me how to apply the proposed config option “MALLOC_ARENA_MAX=1” to kodi config? Thanks

/run/libreelec/kodi.conf
/usr/lib/tmpfiles.d/kodi.conf
/usr/share/debugconf/kodi.conf