Qt-interest Archive, July 2007
Memory leak on windows
Message 1 in thread
Hi,
I'm new to QT and I want to be able to track memory leaks in my
application using the msvcrt builtin memory leak tracker.
I just added 2 lines to the first tutorial:
#include <QApplication>
#include <QPushButton>
#include <crtdbg.h> // ADDED
int main(int argc, char *argv[])
{
_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) |
_CRTDBG_LEAK_CHECK_DF); // ADDED Turn memory leak detection ON
QApplication app(argc, argv);
QPushButton hello("Hello world!");
hello.resize(100, 30);
hello.show();
return app.exec();
}
And at the end of the execution a lot of memory leaks are detected.
I understand that this is not real memory leaks, but pointers that have
to remain allocated during the running time of the application.
But those fake leaks polutes our application output and prevent us to
detect real ones.
Is there any way tio ask QT to free all its pointers before leaving the
application ?
I'm using Qt 4.3.0 with visual 2005
Thanks,
Luc
--
[ signature omitted ]
Message 2 in thread
On 26.07.07 14:09:27, Luc Andre wrote:
> Hi,
>
> I'm new to QT and I want to be able to track memory leaks in my application
> using the msvcrt builtin memory leak tracker.
>
> I just added 2 lines to the first tutorial:
>
> #include <QApplication>
> #include <QPushButton>
>
> #include <crtdbg.h> // ADDED
>
> int main(int argc, char *argv[])
> {
> _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) |
> _CRTDBG_LEAK_CHECK_DF); // ADDED Turn memory leak detection ON
>
> QApplication app(argc, argv);
>
> QPushButton hello("Hello world!");
> hello.resize(100, 30);
>
> hello.show();
> return app.exec();
> }
>
> And at the end of the execution a lot of memory leaks are detected.
> I understand that this is not real memory leaks, but pointers that have to
> remain allocated during the running time of the application.
> But those fake leaks polutes our application output and prevent us to detect
> real ones.
> Is there any way tio ask QT to free all its pointers before leaving the
> application ?
AFAIK Qt does take care of all pointers, the problem is that your leak
detector doesn't detect that (i.e. a bug or such in the detector).
You'll have to filter out those false positives manually.
Andreas
--
[ signature omitted ]