PDA

View Full Version : why there are memory leaks in Qt?



cocalele
19th March 2006, 09:03
Hi,
I have created a simple Qt console application in my VisualStudio2005 with only one main file. The content is list bellow:
#include <afx.h>
#include <QtCore/QCoreApplication>
#define new DEBUG_NEW

int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
return a.exec();
}

You have noticed that I include the afx.h, and I change the “Use of MFC” option to “Use MFC in a Shared DLL” in project property page also. Then I compile and run the pogram, after the program run, I got A LOT OF memory leak messages from VisualStuido’s output window, like this:

Detected memory leaks!

Dumping objects ->

{246} normal block at 0x003DBE38, 24 bytes long.

Data: < > 01 00 00 00 02 00 00 00 01 00 00 00 01 00 00 00

{245} normal block at 0x003DBDF0, 12 bytes long.

Data: < = ( ( > 80 AA 3D 00 28 FF 12 00 28 FF 12 00

...............
...............

So, why this happened? or somthing wrong in my program?

Thanks

dimitri
19th March 2006, 10:55
Nothing wrong with your program.

It could be a bug Visual Studio, you might want to try alternative memory debuggers such as Purify. Anyway, the output of Visual Studio is not helpful, you might need to build Qt and your program in debug mode to get output that makes sense.