Bug 71611 - Memory leak when "Flash the system tray on new messages" enabled
Summary: Memory leak when "Flash the system tray on new messages" enabled
Status: RESOLVED NOT A BUG
Alias: None
Product: kopete
Classification: Unmaintained
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Kopete Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-01-01 20:12 UTC by Sami Nieminen
Modified: 2004-01-05 10:59 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sami Nieminen 2004-01-01 20:12:45 UTC
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.
Comment 1 Martijn Klingens 2004-01-01 21:02:35 UTC
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();
 }


Comment 2 Sami Nieminen 2004-01-03 16:43:42 UTC
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.
Comment 3 Martijn Klingens 2004-01-03 17:06:32 UTC
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
Comment 4 Sami Nieminen 2004-01-03 19:53:12 UTC
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.
Comment 5 Martijn Klingens 2004-01-03 23:27:20 UTC
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.

Comment 6 Sami Nieminen 2004-01-04 22:12:20 UTC
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
Comment 7 Martijn Klingens 2004-01-04 22:46:50 UTC
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.

Comment 8 Sami Nieminen 2004-01-04 23:03:31 UTC
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.
Comment 9 Sami Nieminen 2004-01-05 10:59:46 UTC
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.