Version: (using KDE KDE 3.5.0) Installed from: Gentoo Packages Compiler: g++ (GCC) 3.4.4 (Gentoo 3.4.4-r1, ssp-3.4.4-1.0, pie-8.7.8) OS: Linux The primary artsd process is leaking memory when it plays ogg and mp3 files. Since KDE uses ogg files for sound events, after about a week artsd is using a lot of memory which slows the system down. The VmSize, VmRSS, and VmData all increase at the beginning of ogg playback then when it finishes playing not all of that used memory is freed. I also noticed that when playing a long ogg file the VmRSS will constantly grow by a few kB during every second of playback. The same thing happens with mp3 files but not as bad as with ogg files. Playing wav files however allocates very little memory in artsd and the usage doesn't increase during playback. How to Reproduce: 1. Play an ogg or mp3 file with artsplay, noatun, or a KDE event 2. Watch the artsd memory usage increase while it plays 3. Wait until it finishes playing or manually stop the playback 4. Notice the slightly increased memory usage of the main artsd process since before playing the file
Created attachment 14299 [details] Debug output of Arts playing an ogg file Here is the arts debug log when playing a ogg file in response to a KDE notification. I haven't examined the source code much, but looking through the debug log, it seems that it might be the akode arts plugin that isn't freeing the memory properly since the memory leak doesn't seem to occur when arts plays sound files directly (wav).
I know that this might be a bit complicated but maybe somebody can run artsd in valgrind to find some suspicious places in either artsd or akode.
I've found out that the gradual increase in memory during sound playback is due to akode memory mapping the file so point 2 isn't a problem. Also, getting akodeplay to play a short ogg file many times doesn't increase the memory usage.
Under FreeBSD-6.0 ps axww -O rss,vsz `pgrep artsd` PID RSS VSZ TT STAT TIME COMMAND 47406 11096 16184 ?? S 0:02,90 /usr/local/bin/artsd -F 128 -S 8192 -a toss -m artsmessage -c drkonqi -l 3 -f ps axww -O rss,vsz `pgrep artsd` PID RSS VSZ TT STAT TIME COMMAND 47406 408580 431640 ?? S 95:49,13 /usr/local/bin/artsd -F 128 -S 8192 -a toss -m artsmessage -c drkonqi -l 3 -f
This bug appears to have an adverse affect on SWAP file usage. If left alone, the SWAP file becomes full...my system begins to thrash at that point and all I can do is power down. I've resorted to restarting ARTS whenever I see memory usage increase above 100,000 as reported in KSYSGUARD. This action results in immediate relief in memory usage and swap file usage. Most of my KDE sound activity comes from email notifications and KOPETE notifications. If you run KSYSGUARD and then open KDE Control Center to System Notification, use "Play Sound" with any system notification selected and watch the memory usage increase for ARTSD
Created attachment 14913 [details] kdemultimedia_akode_fix_memory_leak.patch Here is a patch to fix the memory leak. The key to using valgrind to find the problem was to close artsd while the akode plugin was still loaded. Then valgrind was able to see the library where the lost memory was from instead of showing ???.
Could this patch be committed to svn please?
SVN commit 550832 by carewolf: Commit my personal changes, so I am not the only one with an artsd that doesn't leak *shame on me* BUG:119504 M +4 -3 akodePlayObject_impl.cpp --- branches/KDE/3.5/kdemultimedia/akode_artsplugin/akodePlayObject_impl.cpp #550831:550832 @@ -82,6 +82,8 @@ akodePlayObject_impl::~akodePlayObject_impl() { + delete m_packetQueue; + unload(); } @@ -219,10 +221,9 @@ delete bufferedDecoder; bufferedDecoder = 0; } -#else +#endif delete frameDecoder frameDecoder = 0; -#endif decoder = 0; if (buffer != inBuffer) delete inBuffer; @@ -301,7 +302,7 @@ { arts_debug("akode: readFrame"); - if (!buffer || !decoder) return false; + if (!inBuffer || !decoder) return false; if (m_bytebuffer) processQueue(); if(!decoder->readFrame(inBuffer)) { if (decoder->eof()) {
SVN commit 550906 by mpyne: Make the memory leak fix compile. CCBUG:119504 M +1 -1 akodePlayObject_impl.cpp --- branches/KDE/3.5/kdemultimedia/akode_artsplugin/akodePlayObject_impl.cpp #550905:550906 @@ -222,7 +222,7 @@ bufferedDecoder = 0; } #endif - delete frameDecoder + delete frameDecoder; frameDecoder = 0; decoder = 0; if (buffer != inBuffer)