Boost logo

Boost Users :

From: Uwe Schuster (Uwe.Schuster_at_[hidden])
Date: 2007-09-04 03:02:11


> Hi,
>
> I'd appreciate some advice using the Boost unit testing library with
> Qt classes.
>
> I'm using MSVC 8.0 on windows XP.
>
> It appears that simply creating and destroying a QObject
> allocates some
> static datastructures which are reported as a memory leak by
> Boost.Test.
> I'd like to somehow suppress this "static leak" so that Boost.Test may
> find real leaks in my code. Consider the following test program
>
>
> #define BOOST_AUTO_TEST_MAIN
> #include <boost/test/auto_unit_test.hpp>
> #include <Qt/qobject.h>
>
> BOOST_AUTO_TEST_CASE( example )
> {
> BOOST_CHECK_EQUAL( 1, 1 );
> QObject obj;
> }
>
>
> It builds and runs fine, except that memory leaks are detected.
>
> My first line of attack is to clean up after Qt somehow.
> (c.f.
http://lists.trolltech.com/qt-interest/2007-08/thread00997-0.html)

Hello,

 The hack there doesn't work, because the memory leak detection capability is not implemented in Boost.Test itself, it is a feature of the MS VC++ Debug runtime libraries (MSVCRxxD.dll), so the leak detector starts before that application is running.

I think, to solve the issue you have to hack Qt itself, so that the memory is really free'd at program exit time. You can achive this by calling std::atexit( cbFunc ) once after allocating the static pointer. This way you can add a (static) user callback function that is called from runtime library at exit time. In that function you can release the memory from the pointer.

Uwe.

***
The information in this e-mail is confidential and intended solely for the individual or entity to whom it is addressed. If you have received this e-mail in error please notify the sender by return e-mail delete this e-mail and refrain from any disclosure or action based on the information.
***


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net