Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, April 2007
RE: Memory leak in QIcon or setWindowIcon


Message 1 in thread

Just a resend, with the individual files..

> -----Original Message-----
> From: Scott Aron Bloom
> Sent: Wednesday, April 04, 2007 12:12 AM
> To: 'support@xxxxxxxxxxxxx'; Qt-Interest (qt-interest@xxxxxxxxxxxxx)
> Subject: Memory leak in QIcon or setWindowIcon
> 
> Im not sure where the actual leak is, but I have definately found a leak.
> 
> The original project, took some code from the Analog clock example (the
> paint routine) and made a QPixmap out of the image, then it set the window
> icon to the QPixmap, as well as setting the trayicon (from the trayIcon
> example that is out there)
> 
> Essentially my icon was "live" and updated every second...  Please dont
> tell me about the problems with doing this, (like eating computational
> resources) I already know those :)
> 
> if I run the example, i can watch the system memory resources get chewed
> away.  If I comment out the setWindowIcon call in the timerEvent method,
> all is well.
> 
> Its either in the QIcon( QPixmap) constructor, or the setWindowIcon
> method, I reall dont know
> 
> I have attached a VERY simple application showing this.  This bug was
> found on Windows XP, and I do NOT know if it exists on other platforms...
> 
> Any ideas would be most appreciated, I am sending it off to support as
> well.  Also, if you see a "What were you thinking" type of code... I would
> love to hear it... I would love to say I was wrong and there is no mem
> leak here, and it was just my stupidity.
> 
> Scott

Attachment:

Attachment: qiconbug.pro
Description: qiconbug.pro

Attachment: main.cpp
Description: main.cpp

Attachment: MainWindow.cpp
Description: MainWindow.cpp

Attachment: MainWindow.h
Description: MainWindow.h


Message 2 in thread

Hi,

>> if I run the example, i can watch the system memory resources get chewed
>> away.  If I comment out the setWindowIcon call in the timerEvent method,
>> all is well.

Memory leaks are better identified using tools such as Purify. Using the 
Windows task manager is not necessarily reliable. Now, this was just a 
general warning. This is not to say we don't have a real memory leak here.

What do you see exactly when running the program?

Which version of Qt is this?

>> I have attached a VERY simple application showing this.  This bug was
>> found on Windows XP, and I do NOT know if it exists on other platforms...

Unfortunately I don't have Windows to test right now, but I don't see 
any leak on Linux. If there's a leak, it may be in platform-specific code.

--
 [ signature omitted ] 

Message 3 in thread

Agreed... however... the resources available method, will usually take care of itself when the resources get low.  Ie, the app finally starts releasing them.
 
This problem, showed up as a crash with 0 resources available.  
 
My other problem, on windows, Purify is at best less then ideal.. And I don't see the problem on Linux.
 
I think there may be a win32 resource that QT is not releasing in the setWindowIcon bowels or the copy constructor innards.
 
Scott

________________________________

From: Dimitri [mailto:dimitri@xxxxxxxxxxxxx]
Sent: Wed 4/4/2007 1:43 PM
To: qt-interest@xxxxxxxxxxxxx
Subject: Re: Memory leak in QIcon or setWindowIcon



Hi,

>> if I run the example, i can watch the system memory resources get chewed
>> away.  If I comment out the setWindowIcon call in the timerEvent method,
>> all is well.

Memory leaks are better identified using tools such as Purify. Using the
Windows task manager is not necessarily reliable. Now, this was just a
general warning. This is not to say we don't have a real memory leak here.

What do you see exactly when running the program?

Which version of Qt is this?

>> I have attached a VERY simple application showing this.  This bug was
>> found on Windows XP, and I do NOT know if it exists on other platforms...

Unfortunately I don't have Windows to test right now, but I don't see
any leak on Linux. If there's a leak, it may be in platform-specific code.

--
 [ signature omitted ]