Bug 16772

Summary: Xorg memory leak loading Amarok's Cover Manager
Product: xorg Reporter: Mikko C. <mikko.cal>
Component: Server/GeneralAssignee: Default DRI bug account <dri-devel>
Status: RESOLVED NOTOURBUG QA Contact:
Severity: normal    
Priority: high CC: lists
Version: 7.4 (2008.09)   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
Valgrind log, when loading Amarok's Cover Manager. none

Description Mikko C. 2008-07-18 02:42:15 UTC
Created attachment 17739 [details]
Valgrind log, when loading Amarok's Cover Manager.

I have been using xserver, mesa, drm, xf86-video-ati and various dependencies from git since 3d support for r500 cards was merged into master.

I *only* use KDE 4, no compiz.

I have always been experiencing memory leaks in two cases:
- With "Desktop Effects" enabled, minimizing/maximize a window takes about 4mb ram each time, like I explained in this bug (which I don't know if it's the same): http://bugs.freedesktop.org/show_bug.cgi?id=16316

- In Amarok 2.0-SVN, go Tools -> Cover Manager: while loading the thumbnails of the album covers in my collection, X eats *huge* amounts of ram. When it's done loading, X has taken more than 1GB ram (but this of course depends on how many albums are in the collection).

I've always had these leaks, so it's not a recent bug. I hoped this would eventually fix by itself, but I guess it didn't.

I'm not sure the valgrind log I attached is any useful, because it has way too many errors that occur as X starts, so even before the leak is triggered.

This is my VGA:
01:00.0 VGA compatible controller: ATI Technologies Inc Radeon Mobility X1400 (prog-if 00 [VGA controller])

Please let me know what I can to provide useful information to solve this!
Thanks
Comment 1 Michel Dänzer 2008-07-18 04:17:44 UTC
KDE 4 with compositing or without? If with, using XRender or OpenGL? Does changing between these three options have any impact on the observed leaks?

Note that the valgrind log doesn't seem to show any such huge leaks, so it's possible these are actually server resource leaks in the clients. If you restart kwin4 or Amarok, does the X server memory usage go down or at least stop growing for a while?
Comment 2 Mikko C. 2008-07-18 04:55:19 UTC
The first one happens only with Composite enabled (Desktop Effects). And it seems to happen only with openGL. But xrender isn't an option since it's much.

The second happens both with Composite enabled or disabled.

Would it help if I run valgrind on Amarok instead?
But I doubt it's an amarok bug, otherwise I think people would have reported it, since it really trashes the whole system..

If I quit amarok or kwin the ram is still used by the X process.
Comment 3 Mikko C. 2008-07-18 04:56:11 UTC
*much slower, I meant.
Comment 4 Michel Dänzer 2008-07-22 01:27:51 UTC
The compositing minimize/maximize leak should be fixed with the xserver commit below, which has also been merged to the 1.5 branch.

It's unlikely to help for the Amarok leak though, so that probably needs more investigation. E.g. by running the X server from memprof, you could get a leak summary while the X server is still running.

commit d5ae85b5b722821499d5796cf0973ecb6ec125f1
Author: Kristian Høgsberg <krh@redhat.com>
Date:   Mon Jul 21 15:28:50 2008 -0400

    Fix embarrasing GLXPixmap leak.
Comment 5 Mikko C. 2008-07-22 08:56:27 UTC
Thanks Michel, the leak appears to be gone indeed.
About memprof, is there another tool like it? Because memprof depends pretty much on gnome (gconf and libgnomeui), and I rather not install that :)
Comment 6 Michel Dänzer 2008-07-22 09:05:21 UTC
(In reply to comment #5)
> About memprof, is there another tool like it? 

No idea I'm afraid.

> Because memprof depends pretty much on gnome (gconf and libgnomeui), and I
> rather not install that :)


Suit yourself. :)
Comment 7 Mikko C. 2008-11-27 10:05:50 UTC
This is still valid with xorg-server 1.5.3
Comment 8 Mikko C. 2008-12-19 06:12:36 UTC
I just tried a Ubuntu 8.10 liveCD.
The problem is still present.
Install Amarok 2.0 and click on the cover manager: Xorg starts eating ram like crazy.

How do I use memprof to launch X if memprof requires X to run?
Comment 9 Michel Dänzer 2008-12-22 04:45:16 UTC
(In reply to comment #8)
> How do I use memprof to launch X if memprof requires X to run?

From a remote login with ssh X forwarding.
Comment 10 Antoine Pairet 2009-06-13 03:14:47 UTC
Hello!
I do experience the same bug and opened a bug report on Launchpad:
https://bugs.launchpad.net/ubuntu/+source/amarok/+bug/386676

How could I help developers with appropriate informations?
Comment 11 Mikko C. 2009-06-13 03:30:09 UTC
Finally, after almost a year, someone hit the same bug :D
I started thinking there was something wrong with both my PCs.
Antoine, since valgrind output isn't useful you should use memprof to gather more info, but I haven't been able to use it successfully.
Comment 12 Antoine Pairet 2009-06-13 04:07:05 UTC
(In reply to comment #11)
> Finally, after almost a year, someone hit the same bug :D
> I started thinking there was something wrong with both my PCs.
> Antoine, since valgrind output isn't useful you should use memprof to gather
> more info, but I haven't been able to use it successfully.
> 

I tried to find informations regarding the usage of memprof. The problem is the project seems quite old (unmaintained?) and no package is available for Ubuntu in Jaunty Jackalope. I therefore pulled the sources from ftp.gnome.org and tried to build it but I was unsuccessful. 

While ./configure is alright, make fails...

stack-frame.c: In function 'mi_call_with_signal_backtrace':
stack-frame.c:155: error: 'stack_frame' undeclared (first use in this function)
stack-frame.c:155: error: (Each undeclared identifier is reported only once
stack-frame.c:155: error: for each function it appears in.)
stack-frame.c:155: error: 'frame' undeclared (first use in this function)
stack-frame.c:159: warning: left-hand operand of comma expression has no effect
stack-frame.c:159: warning: value computed is not used
stack-frame.c:161: warning: implicit declaration of function 'next_frame'
stack-frame.c:161: warning: left-hand operand of comma expression has no effect
stack-frame.c:161: warning: value computed is not used
stack-frame.c:163: warning: implicit declaration of function 'frame_return_address'
stack-frame.c:163: warning: initialization makes pointer from integer without a cast
make[2]: *** [stack-frame.lo] Error 1
make[2]: Leaving directory `/home/antoine/downloads/memprof-0.6'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/antoine/downloads/memprof-0.6'
make: *** [all] Error 2

Any advice on how to get memprof working on Ubuntu Jaunty?
Where can I find useful documentation?
Is memprof the only way to get information regarding memory usage of programs? 

Regarding my setup, I use Ubuntu Jaunty Jackalope with packages from xorg-edger PPA which means I use
 kernel 2.6.30 
 ati driver with git (2009 06 11)
Detailed information can be found at https://launchpad.net/~xorg-edgers/+archive/ppa

My card is
(--) PCI:*(0@1:5:0) ATI Technologies Inc Radeon Xpress 1250 rev 0, Mem @ 0xd8000000/134217728, 0xd0100000/65536, I/O @ 0x00009000/256

regards,
Comment 13 Chris Wilson 2009-06-13 04:35:59 UTC
(In reply to comment #12)
> Is memprof the only way to get information regarding memory usage of programs? 

I use http://cgit.freedesktop.org/~ickle/odin -- but be warned that's been written to meet my needs and little else. ;-)

A simpler tool is http://cgit.freedesktop.org/cairo/tree/util/malloc-stats.c which just needs to be compile to a shared library and preloaded.
Comment 14 Michel Dänzer 2009-06-15 06:57:37 UTC
(In reply to comment #13)
> I use http://cgit.freedesktop.org/~ickle/odin -- but be warned that's been
> written to meet my needs and little else. ;-)

Looks very nice, nice choice of name as well. :)

In particular, like memprof this shows where the memory was allocated at any time, not only at process termination.

> A simpler tool is http://cgit.freedesktop.org/cairo/tree/util/malloc-stats.c
> which just needs to be compile to a shared library and preloaded.

Not sure what this offers over valgrind on a quick glance.
Comment 15 Mikko C. 2009-06-15 08:17:11 UTC
Pardon my ignorance but how do I compile odin?
I tried executing configure.in but got this:
./configure.in: line 1: syntax error near unexpected token `2.54'
./configure.in: line 1: `AC_PREREQ(2.54)'

I have autoconf 2.63
Comment 16 Mikko C. 2009-06-20 02:14:13 UTC
More people confirmed this huge leak:
http://amarok.kde.org/forum/index.php/topic,16784.0.html
https://bugs.kde.org/show_bug.cgi?id=197242
Comment 17 Mikko C. 2009-07-20 05:18:13 UTC
I changed the title and product, since it happens with nvidia and intel cards too.
Comment 18 Mikko C. 2009-07-20 05:44:57 UTC
Antoine, are you on amd64 too?
If os, this could be arch specific...
Comment 19 Antoine Pairet 2009-07-31 05:40:59 UTC
(In reply to comment #18)
> Antoine, are you on amd64 too?
> If os, this could be arch specific...
> 
Yes, my architecture is 64 bits. 
Comment 20 Michel Dänzer 2010-12-15 02:35:53 UTC
According to the KDE bug report this was a bug in Amarok.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.