slimserver icon indicating copy to clipboard operation
slimserver copied to clipboard

I have a memory leak

Open baslking opened this issue 1 year ago • 22 comments

As of 9.0 May 25 commit, I have a memory leak. This is new, never seen it before. I pick up about 100KB on every new song being streamed from Tidal, haven't tried on local files, will do that tomorrow.

I'm using a bit of an esoteric version on Arch Linux, but I've been running for months on it. This is perl 5, version 38, subversion 2 (v5.38.2) built for aarch64-linux-thread-multi Operating System: Arch Linux ARM
Kernel: Linux 6.6.31-2-rpi Architecture: arm64

Lyrion Music Server Version: 9.0.0 - git-efa83999f @ 2024-05-25 11:13:29 +0200 Hostname:xxxx Server IP Address:xxx.xxx.xxxx.xxxx Server HTTP Port Number: 9000 Operating system: Linux - EN - utf8 Platform Architecture: aarch64-linux Database Version: SQLite Total Players Recognized: 2

Perl and Module Versions Perl Version: 5.38.2 - aarch64-linux-thread-multi Audio::Scan: 1.09 DBD::SQLite: 1.58 (sqlite 3.22.0) IO::Socket::SSL: 2.085 Mozilla::CA: Net::SSLeay: 1.94 - OpenSSL 3.3.0 9 Apr 2024

The slimserver-vendor package hasn't been updated for the last few weeks. I recognise that this is probably not enough info, but maybe someone else is seeing this?

baslking avatar May 25 '24 20:05 baslking

seems to be leaking roughly 1M/song played either streamed from service or local files.

baslking avatar May 26 '24 08:05 baslking

It's growing with every song, or does it settle after a while? How much is it using overall? What plugins are you using?

michaelherger avatar May 26 '24 13:05 michaelherger

The main plugin that I'm really using is Tidal I have quite a few others turned on (search and tagging etc) I just launched off about 2500 local songs and I'll keep an eye on it. it's running around 180M as a starting point. It seemed to keep growing streaming tidal for about 100 songs, but I didn't push too far before restarting. I'll give it a day or 2

baslking avatar May 28 '24 20:05 baslking

Just ran for 301 local songs. I started at 185MB and now it's at 234MB growing fairly steadily at about 160MB/song. I recompiled the CPAN modules before starting just in case (my distribution only has Perl 5.38 so there isn't an off the shelf build) I will continue to watch it, but after about 24hours I don't think it will level off. If nobody else is seeing this its probably something with my CPAN build. The players don't need any decoding so none of the helper binaries are running.

baslking avatar May 29 '24 20:05 baslking

Can you check your numbers? 160MB/song times 301 song would result in... 48GB. I guess this should be 160kB?

A certain growth after restart can be considered normal. Caches are filling up here and there, the database is filling its buffers etc. But it should certainly level off at some point.

FWIW: my main LMS is currently at 229MB. But I admittedly restart quite often (every other day), as I'm trying to always run the latest and greatest.

michaelherger avatar May 29 '24 22:05 michaelherger

Sorry, that is indeed 160kb/song. I,like you, have been updating and restarting every day or so with your frequent updates 👍 . I'll keep running for another couple days and see. My process has gone from 185MB to 248MB. 63MB seems like a lot, but maybe not.

baslking avatar May 30 '24 07:05 baslking

As long as it doesn't further grow that's fine.

michaelherger avatar May 30 '24 15:05 michaelherger

I'm at 306MB at 800 songs played still growing at 150KB/song after about 60hours

baslking avatar May 31 '24 15:05 baslking

Yeah, something's not quite right, I'd say. Are you using any 3rd party plugins? What is your memory setting in Settings/Advanced/Performance?

michaelherger avatar May 31 '24 21:05 michaelherger

Just upgraded and restarted at 1001 songs, seems to be slowing but still growing: went from 185M to 326MB still growing over 100KB/song after 3 days. It's a 1GB RPI. I had run for months back in the days of LMS when I used a binary distribution and upgrades were infrequent. Best i can tell no 3rd party plugins. Here's the perf settings, pretty plain vanilla:

Screenshot 2024-06-01 at 17 09 00

baslking avatar Jun 01 '24 15:06 baslking

Something's wrong there. What startup parameters are you using? I just bumped into an issue with my dev system where after about a day it had consumed >16GB! But that most likely was due to my using the --checkstrings parameter, which monitors changes to the strings file in an inefficient way.

michaelherger avatar Jun 03 '24 05:06 michaelherger

/home/slimserver/git/slimserver/slimserver.pl
--prefsdir /home/slimserver/prefs
--cachedir /home/slimserver/cache
--logdir /var/log/slimserver with the packaged perl: perl --version

This is perl 5, version 38, subversion 2 (v5.38.2) built for aarch64-linux-thread-multi

baslking avatar Jun 05 '24 15:06 baslking

I think I've found something. After the 8 June upgrade with the reworking of the sql database I restarted and ran 150 songs with no memory leak, but I had been doing testing with 2 players running synchronized, and I switched to 1 player. To check if it's the updates or the 2 player sync I'm now running 2 players synchronized, if there's a leak would appear to be related to that. I can imagine that some sort of buffering might be needed to synchronize 2 players,? If not then it was fixed by some of the updates. Now running: Lyrion Music Server Version: 9.0.0 - git-bad40f25b @ 2024-06-09 07:58:30 +0200 I'll see where its at in a few hours.

baslking avatar Jun 09 '24 07:06 baslking

So i can confirm memory grows about 150KB/song with 2 players in sync and it appears stable with a single player.

baslking avatar Jun 10 '24 07:06 baslking

Are you using sync ad-hoc, or do you use the Group Player plugin?

michaelherger avatar Jun 10 '24 08:06 michaelherger

I wasn't aware of the group player plugin, so I suppose ad-hoc, I've used it for years. I'll try the plugin...

baslking avatar Jun 12 '24 10:06 baslking

I'm sure you mentioned what players you're using. Would you know whether transcoding is involved? Eg. would one of the players require the audio data to be transcoded form some format to something else?

michaelherger avatar Jun 12 '24 12:06 michaelherger

So group and ad-hoc give similar results about 150K/song. I saw 66MB after 420 songs played I'm using squeezelite players that should not need any transcoding. My original hw is long dead. I also seem to see similar results for local and streaming content. I don't want to waste your time. It's easy enough to restart, especially If I am the only one with an issue

baslking avatar Jun 14 '24 07:06 baslking

Update here, after updating to Perl 5.40, I'm seeing 13.5KB/song which grows much more slowly. So things are getting better.

Lyrion Music Server Status
Lyrion Music Server Version: 9.0.0 - git-f6ef66f16 @ 2024-09-09 09:43:19 +0200
Hostname: majordomo
Server IP Address: 172.16.16.13
Server HTTP Port Number: 9000
Operating system: Linux - EN - utf8
Platform Architecture: aarch64-linux
Database Version: SQLite
Total Players Recognized: 3
 
Perl and Module Versions
Perl Version: 5.40.0 - aarch64-linux-thread-multi
Audio::Scan: 1.09
DBD::SQLite: 1.58 (sqlite 3.22.0)
IO::Socket::SSL: 2.089
Mozilla::CA: Unknown
Net::SSLeay: 1.94 - OpenSSL 3.3.2 3 Sep 2024

baslking avatar Sep 10 '24 21:09 baslking

This is looking like it is resolved via updates notably the 5.40 version of Perl. I ran a bit over 1500 songs and somewhere around 1000 the storage peaked at a modest value (about 330MB) stabilized then dropped a bit. The CPU usage is also really low with the latest version ~4% of 1CPU on a Raspberry Pi

Lyrion Music Server Version: 9.0.0 - git-7c8a896b7 @ 2024-10-29 14:14:28 +0100
Hostname: majordomo
Server IP Address: 172.16.16.13
Server HTTP Port Number: 9000
Operating system: Linux - EN - utf8
Platform Architecture: aarch64-linux
Database Version: SQLite
Total Players Recognized: 3
 
Perl and Module Versions
Perl Version: 5.40.0 - aarch64-linux-thread-multi
Audio::Scan: 1.10
DBD::SQLite: 1.58 (sqlite 3.22.0)
IO::Socket::SSL: 2.089
Mozilla::CA: Unknown
Net::SSLeay: 1.94 - OpenSSL 3.4.0 22 Oct 2024

baslking avatar Nov 04 '24 19:11 baslking

Are you using the Radio Paradise plugin? I found a memory leak in there a week or two ago.

michaelherger avatar Nov 04 '24 21:11 michaelherger

Hmm. no not familiar with it.

baslking avatar Nov 13 '24 00:11 baslking