Version: (using KDE Devel) Installed from: Compiled sources Compiler: gcc 3.3.2 OS: Linux Kopete starts leaking memory if I have the option "Flash the system tray on new messages" enabled and I receive a message (when not having a chat window already open). If I disable this option, memory does not leak. In this way kopete leaks about 100MB of memory in one hour (leading to kopete getting killed by the kernel eventually). I am using qt-copy from CVS which is QT 3.3.0-beta1 and less than a week old versions of kdelibs and kdenetwork.
Subject: kdenetwork/kopete/kopete CVS commit by mklingens: Workaround for the pixmap leakage in QMovie: pause the movie while not being shown. This avoids the initial leaking, although eventually there might still be a leak up to the size of Qt's pixmap cache. The leak is not infinite, but this should improve performance a bit and makes sure that attempts to measure Kopete's resource usage aren't massively skewed. Also note that closing the chat window frees the pixmaps, so the memory isn't permanently lost either in a Kopete session. If there are any other leaks that are properly reproducable (data from valgrind running in leak-check mode is also welcome, as long as it's a leak check on a running Kopete and not on exit, and with proper details on when the check was run) please report in a separate bug report. CCMAIL: 62669-fixed@bugs.kde.org CCMAIL: 71611-fixed@bugs.kde.org M +19 -35 systemtray.cpp 1.34 M +3 -0 chatwindow/kopeteemailwindow.cpp 1.30 --- kdenetwork/kopete/kopete/systemtray.cpp #1.33:1.34 @@ -139,8 +139,9 @@ void KopeteSystemTray::startBlink( const } -void KopeteSystemTray::startBlink( const QMovie &icon ) +void KopeteSystemTray::startBlink( const QMovie &movie ) { kdDebug( 14010 ) << k_funcinfo << "starting movie." << endl; - setMovie( icon ); + const_cast<QMovie &>( movie ).unpause(); + setMovie( movie ); mIsBlinking = true; } @@ -148,5 +149,6 @@ void KopeteSystemTray::startBlink( const void KopeteSystemTray::startBlink() { - if( mMovie.isNull() ) + if ( mMovie.isNull() ) + { #if KDE_IS_VERSION(3, 1, 90) mMovie = KGlobal::iconLoader()->loadMovie( QString::fromLatin1( "newmessage" ), KIcon::Panel ); @@ -154,4 +156,6 @@ void KopeteSystemTray::startBlink() mMovie = KopeteCompat::loadMovie( QString::fromLatin1( "newmessage" ), KIcon::Panel ); #endif + } + startBlink( mMovie ); } @@ -159,41 +163,22 @@ void KopeteSystemTray::startBlink() void KopeteSystemTray::stopBlink() { - if(movie()) - { - kdDebug(14010) << k_funcinfo << "stopping movie." << endl; - setPixmap(mKopeteIcon); - mIsBlinkIcon = false; - mIsBlinking=false; - return; - } - - if (mBlinkTimer->isActive() == true) - { + if ( movie() ) + kdDebug( 14010 ) << k_funcinfo << "stopping movie." << endl; + else if ( mBlinkTimer->isActive() ) mBlinkTimer->stop(); - setPixmap(mKopeteIcon); - mIsBlinkIcon = false; - mIsBlinking = false; - } - else - { - setPixmap(mKopeteIcon); + if ( !mMovie.isNull() ) + mMovie.pause(); + mIsBlinkIcon = false; mIsBlinking = false; - } + setPixmap( mKopeteIcon ); } void KopeteSystemTray::slotBlink() { - if (mIsBlinkIcon == true) - { - setPixmap(mKopeteIcon); - mIsBlinkIcon = false; - } - else - { - setPixmap(mBlinkIcon); - mIsBlinkIcon = true; - } + setPixmap( mIsBlinkIcon ? mKopeteIcon : mBlinkIcon ); + + mIsBlinkIcon = !mIsBlinkIcon; } --- kdenetwork/kopete/kopete/chatwindow/kopeteemailwindow.cpp #1.29:1.30 @@ -282,4 +282,5 @@ void KopeteEmailWindow::initActions(void d->animIcon = KopeteCompat::loadMovie( QString::fromLatin1( "newmessage" ), KIcon::Toolbar); #endif + d->animIcon.pause(); d->anim = new QLabel( this, "kde toolbar widget" ); @@ -519,4 +520,5 @@ void KopeteEmailWindow::sendMessage() d->sendInProgress = true; d->anim->setMovie( d->animIcon ); + d->animIcon.unpause(); d->btnReplySend->setEnabled( false ); d->txtEntry->setEnabled( false ); @@ -529,4 +531,5 @@ void KopeteEmailWindow::messageSentSucce d->sendInProgress = false; d->anim->setPixmap( d->normalIcon ); + d->animIcon.pause(); closeView(); }
I still have this leak. Unfortunately valgrind does not compile on a system with NPTL instead of LinuxThreads so I don't know what to do to help investigate this more.
Well, yes, what you're still seeing is the Qt part that I can't do anything about. It's not leaking infinitely, it stops at about 3 Mb pixmap memory (the size of Qt's pixmap cache), and that's also why valgrind doesn't complain: technically it's not a leak because eventually the resources do get properly freed. My patches were only trying to minimize the effect by pausing the animation while it's not being shown. That's all I can do in Kopete, sorry. (See also the discussion on kde-core-devel BTW for more information about what's causing this problem, http://lists.kde.org/?l=kde-core-devel&m=107296720812879&w=2) Martijn
Hmmm, this must be different leak then, because xrestop currently only shows pixmap mem usage of around 130k while with top I see the memory usage growing gradually (currently VIRTUAL: 143m, RES: 128m, SHR: 37m) until it eats all available memory (~500MB) and finally kernel kills the process. I'll try updating kdelibs or downgrading qt to see if that makes any difference.
Subject: Re: [Kopete-devel] Memory leak when "Flash the system tray on new messages" enabled On Saturday 03 January 2004 19:53, Sami Nieminen wrote: > Hmmm, this must be different leak then, because xrestop currently > only shows pixmap mem usage of around 130k while with top I see the memory > usage growing gradually (currently VIRTUAL: 143m, RES: 128m, SHR: 37m) > until it eats all available memory (~500MB) and finally kernel kills the > process. I'll try updating kdelibs or downgrading qt to see if that makes > any difference. Oh, I never saw that, but after seeing the problem in xrestop I ever actually checked 'normal' top, I have to admit. Plain top is notoriously inaccurate so I tend to ignore it, but if it's really leaking that should still show up. How can I reproduce that? And does this also occur with all protocols or is it more specific? And with what plugins loaded is this? Notably history, but others might matter too.
For me it is reproducable every time, when I have enabled that option "Flash the system tray on new messages" and I receive a message from someone for whom I don't have a chat window already open. Memory usage seems to grow as long as the kopete icon on system tray spins (i.e. until I click on the "View" button of the bubble. I disabled all plugins, and connected only my msn account and problem occurs. Before this I used my icq account for doing the test so I don't think it is related to particular protocol. On that discussion thread about the QMovie problem someone [1] mentions a diff that allows you to dump the pixmaps to disk and says "Also, at any rate, there do seem to be an awful lot of the spinning Kopete logo pixmaps in there..". Does xrestop show all of those also? Like I said, for me xrestop doesn't show anything leaking (around 270k of pixmap mem usage at the moment and it doesn't grow), while the VIRTUAL AND RES numbers on normal top are growing as long as I don't open the chat window to view the message. [1] http://lists.kde.org/?l=kde-core-devel&m=107298440324722&w=2
Subject: Re: [Kopete-devel] Memory leak when "Flash the system tray on new messages" enabled On Sunday 04 January 2004 22:12, Sami Nieminen wrote: > On that discussion thread about the QMovie problem someone [1] mentions a > diff that allows you to dump the pixmaps to disk and says "Also, at any > rate, there do seem to be an awful lot of the spinning Kopete logo pixmaps > in there..". Does xrestop show all of those also? Like I said, for me > xrestop doesn't show anything leaking (around 270k of pixmap mem usage at > the moment and it doesn't grow), Hmm, that's not even remotely what I get, as the pixmap memory grows up to some fixed amount and then stalls. I can't even reproduce this here :( Could it be a qt bug? I'm running 3.2 from qt-copy CVS with the patches in KDE CVS applied.
It might be a qt bug as I am currently using the 3.3.0-beta1 version (qt-copy). I didn't try with qt 3.2 branch of qt-copy yet, but I will do that next. I updated kdelibs and kdenetwork from CVS last night, but that didn't change anything.
I downgraded to qt 3.2 branch and recompiled kde. Now I see pixmap mem usage on xrestop growing to around 2070k and staying there, and normal top doesn't show growing memory usage anymore. There is no spinning kopete icon on systray anymore though, seem that the icon has been just changed. Anyway, qt 3.3.0-beta1 seems to behave quite differently and probably has some sort of bug.