Bug 298627 - Amarok memory leak when changing tracks
Summary: Amarok memory leak when changing tracks
Status: RESOLVED WORKSFORME
Alias: None
Product: amarok
Classification: Applications
Component: general (show other bugs)
Version: 2.6.0
Platform: unspecified Linux
: NOR normal
Target Milestone: 2.8
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-22 22:59 UTC by Daniel Nicoletti
Modified: 2013-08-17 23:40 UTC (History)
16 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Output of valgrind - part AA (1 of 3) (976.56 KB, text/plain)
2012-05-24 02:45 UTC, Gerald Cox
Details
Output of valgrind - part AB (2 of 3) (976.56 KB, text/plain)
2012-05-24 02:46 UTC, Gerald Cox
Details
Output of valgrind - part AC (3 of 3) (89.01 KB, text/plain)
2012-05-24 02:47 UTC, Gerald Cox
Details
valgrind log, scripts & modules disabled (116.63 KB, application/zip)
2012-12-06 14:31 UTC, shaddowy2
Details
valgrind log, typical scripts & modules enabled (325.19 KB, application/zip)
2012-12-06 14:32 UTC, shaddowy2
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Nicoletti 2012-04-22 22:59:11 UTC
Amarok is leaking a lot here,
it starts with 80mb but after a whole day playing it gets to > 500mb,
the behavior I see is that 2~3 seconds 200kb is allocated, and when
I move to the next track ~1mb is allocated...
I have two valgrind logs VLC and Gstreamer.

hope it helps.
best
Comment 1 Daniel Nicoletti 2012-04-22 23:00:57 UTC
VLC
http://privatepaste.com/e0b912973a

GStreamer
http://privatepaste.com/45263f7f39
Comment 2 Daniel Nicoletti 2012-04-22 23:04:05 UTC
I think the VLC one wasn't completely written when I CTRL + C it,
So here's the full version:
http://privatepaste.com/dccae94e34
Comment 3 Gerald Cox 2012-05-23 02:57:39 UTC
I'm having the same issue.  Easily reproducible - just load up a playlist and select the repeat playlist option.  The only plugins I am using are mass storage device and lastfm.  I ran the following command to document the leak:  top -b -d 150 -p 11866 > amarok.txt

I then imported the results into a google spreadsheet you can view here:
http://goo.gl/Q4bZw

Memory utilization started out at 7.4% and ended up at 31.9% after approx 48 hours.  The leak is steady and unrelenting.  I ran the same playlist under QMMP during the same period and memory utlization was steady at 2.5% throughout the period.
Comment 4 Matěj Laitl 2012-05-23 08:24:16 UTC
Gerald, please install Amarok debugging symbols, valgrind and run Amarok from console under valgrind: valgrind --leak-check=full amarok --debug --nofork

If you're able to compile current git version, it would help us even more because some of the memory leaks could have been already resolved. A guide how to do that: 
http://blogs.fsfe.org/myriam/2009/09/compiling-amarok-from-git-locally-full-summary/ (please uninstall distribution Amarok package first)

Reproduce the big memory leak (run Amarok for 2 days), exit it cleanly and then attach valgrind report here; that will help us identify where the memory is lost. Note that Amarok can run considerably slower under valgrind - it is okay, valgrind has to emulate CPU.
Comment 5 Gerald Cox 2012-05-24 02:45:01 UTC
Created attachment 71334 [details]
Output of valgrind - part AA (1 of 3)

I don't believe it is necessary to run valgrind for 2 days.  If you look at the google spreadsheet I posted you will see that the increase in memory utilization is steady.  I ran valgrind for approximately 7 hours, hopefully that will show you what you need.  

The leak summary is as follows:
LEAK SUMMARY:
definitely lost: 62,785 bytes in 421 blocks
indirectly lost: 462,826 bytes in 5,620 blocks
possibly lost: 39,984,957 bytes in 186,836 blocks
still reachable: 4,335,737 bytes in 20,146 blocks
suppressed: 0 bytes in 0 blocks
Comment 6 Gerald Cox 2012-05-24 02:46:43 UTC
Created attachment 71335 [details]
Output of valgrind - part AB (2 of 3)
Comment 7 Gerald Cox 2012-05-24 02:47:39 UTC
Created attachment 71336 [details]
Output of valgrind - part AC (3 of 3)
Comment 8 Matěj Laitl 2012-05-25 20:53:18 UTC
(In reply to comment #7)
> Created attachment 71336 [details]
> Output of valgrind - part AC (3 of 3)

Thanks for your cooperation, Cerald. We're currently going through your valigrind reports. There ary _many_ things, to it may take us some time to sort it out.

Amarok devs: the leaks are sorted by size, the biggest ones are in part AC.
Comment 9 Gerald Cox 2012-05-25 23:11:39 UTC
No problem, let me know if you need additional information.  Thanks!
Comment 10 matt 2012-06-29 14:01:33 UTC
This bug has been plaguing me for a while (causing my laptop to run out of memory and basically lock up on hard-drive virtual memory access).  Has there been any movement/improvements?  Also, is this bug related to the reason Amarok likes to just stop playing a few seconds into a track that it "fell into" (ie. I didn't immediately tell it to play that song)?  Thanks.
Comment 11 Myriam Schweingruber 2012-06-30 07:42:24 UTC
Subscribing the phonon developers, apparently the leak is both in our database handling, engines and the gstreamer backend.
Comment 12 Harald Sitter 2012-07-30 13:34:33 UTC
Missing debug symbols for phonon_gstreamer, so the logs are not particularly useful.

FWIW, I recently did a code review for memleaks though I did not find any particularly big leaks. I am however reasonable certain there is a rather grave one somewhere, I just can't seem to find it.
Also a general note: gstreamer passively leaks through its init function, much like QLibrary the memory is meant to free'd on exit by libc.
Comment 13 matt 2012-07-30 21:14:20 UTC
still leaking, *and stopping playing* between tracks.  not all the time, but the leak is more consistent than the stopping.
Comment 14 Marco Cimmino 2012-09-11 04:24:24 UTC
Not sure if related, but today I had 2 GB of amarok process, guys are still stuck with reading valgrind's reports or do you think you can fix this?
Comment 15 Myriam Schweingruber 2012-09-11 14:11:59 UTC
Could you all please upgrade to Amarok 2.6 and the newer phonon backends? phonon-backend-gstreamer is currently at 4.6.2 and the phonon-backend-vlc at 0.6.0
Comment 16 Myriam Schweingruber 2012-10-21 09:32:19 UTC
Dear all, I really need your feedback with Amarok 2.6 and the new phonon-backend-gstreamer 4.6.2, else it doesn't make much sense to keep this report open. Please respond.
Comment 17 Daniel Nicoletti 2012-10-21 12:46:04 UTC
Yes, I have phonon-gstreamer-4.7 on kubuntu 12.10.
I start Amarok, krunner shows 40mb
I click next track a bunch of times and the memory goes
increasing...
IMO the valgind reports are really helpful to figure out
what's wrong, there's a lot of definitely lost blocks.
Comment 18 Harald Sitter 2012-10-21 14:15:54 UTC
>IMO the valgind reports are really helpful to figure out what's wrong, there's a lot of definitely lost blocks.

except they amount to a total of like 0.3 lost MiB and are not active leaks
Comment 19 Daniel Nicoletti 2012-10-21 14:45:47 UTC
well then there might be lots of new Foo(this) that never get deleted as the parent is still alive..
Comment 20 Alassane 2012-10-22 06:07:05 UTC
So this is how amarok tend to eat up more and more memory as time pass. I can definitely confirm I have this bug with 2.6 and gstreamer backend 4.6.2. Let me know if you need more debuging symbols.
Comment 21 Myriam Schweingruber 2012-10-22 09:06:19 UTC
Except these valgrind outputs are not from Amarok 2.6, please provide a new one. Beforehand, please disable all 3rd-party scripts.

I can't reproduce this here at all, Amarok has been open and playing for over 48 hours now, the total shared memory use is 30 MB.

Amarok 2.6-git, no external scripts, KDE 4.9.2, phonon-backend-vlc 0.6.0
Comment 22 Harald Sitter 2012-10-22 11:44:52 UTC
>Amarok 2.6-git, no external scripts, KDE 4.9.2, phonon-backend-vlc 0.6.0

It would only leak with gstreamer btw.
Comment 23 Myriam Schweingruber 2012-12-04 15:48:20 UTC
Please, everybody, we need a valgrind output from Amarok 2.6 with the phonon-gstreamer-backend 4.6.2, else there is not much hope of ever fixing this.
Without the requested feedback I will have to close this report.
Comment 24 Alassane 2012-12-05 04:36:51 UTC
I have been trying to today but valgrind and/or amarok keeps crashing whenever I try to skip to the next song. Should I post the output nonetheless?
Comment 25 Myriam Schweingruber 2012-12-05 12:55:01 UTC
(In reply to comment #24)
> I have been trying to today but valgrind and/or amarok keeps crashing
> whenever I try to skip to the next song. Should I post the output
> nonetheless?

Try only putting tracks of the same type in the playlist, as the gstreamer backend has some issues with switching songs of different types. Of course make sure to use the latest 4.6.2 version of that backend
Comment 26 shaddowy2 2012-12-06 14:31:19 UTC
Created attachment 75656 [details]
valgrind log, scripts & modules disabled

Here is my valgrind output. Amarok 2.6 with all modules & third party scripts disabled. Phonon-gstreamer 4:4.7.0really4.6.2-0ubuntu1. 
I listened to 27 tracks, some of them were skipped by myself to accelerate the process.
Comment 27 shaddowy2 2012-12-06 14:32:32 UTC
Created attachment 75657 [details]
valgrind log, typical scripts & modules enabled

Here is another log, this time I enabled my typical scripts (ultimate lyrics, copy selected tracks, delete current playing file, librivox and radio germany) & modules (local file back-end and lastfm) in Amarok.

Observations: Amarok did choke sometimes some seconds at the beginning of a track or in the middle of it. I believe that is caused by the emulation work valgrind has to do? Never saw that in my regular usage.
Comment 28 Myriam Schweingruber 2012-12-06 15:04:31 UTC
Thank you for the feedback.
Comment 29 Matěj Laitl 2013-01-01 23:16:43 UTC
Git commit d9904f05ce8b8a634f90bc361abe11a6dd18465e by Matěj Laitl.
Committed on 02/01/2013 at 00:11.
Pushed by laitl into branch 'master'.

PlaylistBreadcrumbItemSortButton: fix small memleak

Thanks to Jekyll Wu <adaptee@gmail.com> who found it. The fix is
a simpler version of Jekyll's patch.
REVIEW: 108050

M  +2    -2    src/playlist/PlaylistBreadcrumbItemSortButton.cpp

http://commits.kde.org/amarok/d9904f05ce8b8a634f90bc361abe11a6dd18465e
Comment 30 Richard Pace 2013-06-18 18:52:59 UTC
Hi:
Just upgraded to OpenSuSE 12.3 with Amarok 2.7.0 using Gstreamer 4.6.2.  I still have a memory memory leak of .2M every few seconds.  My playlist is a Radio station url - I don't switch tracks.  Just stream the Radio station all day.  

Here is the Amarok diagnostic display:
Amarok Diagnostics

Amarok Version: 2.7.0
KDE Version: 4.10.3 "release 1"
Qt Version: 4.8.4
Phonon Version: 4.6.0
Phonon Backend: GStreamer (4.6.2)
PulseAudio: Yes

Amarok Scripts:
    Amarok Script Console 1.0 (stopped)
Lyricwiki .2 (stopped)
Free Music Charts 1.6.0 (stopped)
Librivox.org 1.0 (stopped)
Cool Streams 1.0 (stopped)

Amarok Plugins:
    AudioCd Collection (disabled)
DAAP Collection (disabled)
MTP Collection (disabled)
MySQLServer Collection (enabled)
MySQLe Collection (enabled)
Nepomuk Collection (disabled)
UPnP Collection (disabled)
Universal Mass Storage Collection (disabled)
iPod, iPad & iPhone Collection (disabled)
Ampache (disabled)
Jamendo (disabled)
Last.fm (disabled)
MP3 Music Store (disabled)
MP3tunes (disabled)
Magnatune Store (disabled)
Podcast Directory (disabled)
gpodder.net (disabled)
Comment 31 Daniel Nicoletti 2013-06-18 18:57:36 UTC
I think I found the root of the issue, but I dunno where it leaks.
The lyrics and wiki information that Amarok retrieves is what
is causing this, if I remove both this issue doesn't happen,
so it might be WebKit leaking or something.
Can you guys try removing those containers and see if it still leaks?

Thanks.
Comment 32 Myriam Schweingruber 2013-06-18 19:23:16 UTC
Please, everybody, upgrade your Amarok to 2.7.1 and your phonon-backend-gstreamer to 4.6.3, this is largely fixed by now. I haven't seen a memory leak on track change in ages on current git either.
Comment 33 Richard Pace 2013-06-18 23:38:47 UTC
Upgraded to Amarok 2.7.1 and Phonon backend gstreamer 4.6.3.  I still have memory leak.  Streaming Radio url all day.  Every few seconds memory increases by .3M or so.  e.g. right now memory is 59.4M - started around 44.0M about 5 minutes ago.

I have all the bells and whistles disabled (e.g. no lyrics, wiki, etc.)

Amarok Diagnostics

Amarok Version: 2.7.1
KDE Version: 4.10.3 "release 1"
Qt Version: 4.8.4
Phonon Version: 4.6.0
Phonon Backend: GStreamer (4.6.3)
PulseAudio: Yes

Amarok Scripts:
    Amarok Script Console 1.0 (stopped)
Lyricwiki .2 (stopped)
Free Music Charts 1.6.0 (stopped)
Librivox.org 1.0 (stopped)
Cool Streams 1.0 (stopped)

Amarok Plugins:
    AudioCd Collection (disabled)
DAAP Collection (disabled)
MTP Collection (disabled)
MySQLServer Collection (enabled)
MySQLe Collection (enabled)
Nepomuk Collection (disabled)
UPnP Collection (disabled)
Universal Mass Storage Collection (disabled)
iPod, iPad & iPhone Collection (disabled)
Ampache (disabled)
Jamendo (disabled)
Last.fm (disabled)
MP3 Music Store (disabled)
MP3tunes (disabled)
Magnatune Store (disabled)
Podcast Directory (disabled)
gpodder.net (disabled)
Comment 34 Richard Pace 2013-06-18 23:53:59 UTC
FYI, tried to run Amarok in console using Valgrind (as mentioned in a previous post).  However, after intialization, Amarok crashes when I select the url from the playlist to stream.
Comment 35 Richard Pace 2013-06-21 21:31:16 UTC
I have installed VLC and running with phonon VLC backend now -  Memory is stable.  Abandoning gstreamer backend for now.
Comment 36 Myriam Schweingruber 2013-07-22 00:07:14 UTC
Closing correctly.
Comment 37 Rael Gugelmin Cunha 2013-08-17 12:51:45 UTC
Here I have to select: use VLC to not be affected by this bug (memory leak on change track), or use Gstream and cannot resume streaming playback (https://bugs.kde.org/show_bug.cgi?id=311953).
Comment 38 Myriam Schweingruber 2013-08-17 23:40:38 UTC
(In reply to comment #37)
> Here I have to select: use VLC to not be affected by this bug (memory leak
> on change track), or use Gstream and cannot resume streaming playback
> (https://bugs.kde.org/show_bug.cgi?id=311953).

Sorry, not much we can do about that, the memory leak is in gstreamer, please address that to the right people.