Boost logo

Boost Users :

Subject: Re: [Boost-users] [Test] How to treat memory leaks as errors?
From: OvermindDL1 (overminddl1_at_[hidden])
Date: 2009-09-20 16:56:55


2009/9/20 Василий Старостин <bstarostin_at_[hidden]>:
>                                        Hi!
>
>>> However, Boost.Test doesn't return non-zero error code when leaks
>>> detected (as it does this when tests fail).
>
>>> How can I make my testing program to return non-zero error code if memory leaked?
>
>>Because Boost.Test does not contain anything that can test for memory
>>leaks.  You might want to use something like Google's tcmalloc and so
>>forth as it can tell you about all that, and you can just add a
>>Boost.Test testcase at the end of the tests to check for memory leaks
>>using it.
>
> Boost.Test does contain something to test memory leaks since I get
> such warnings when I loose memory in my Boost.Test-based program :)
>
> I know this is _CRT functions (I use MSVC9). And the function, which
> Boost.Test uses to inform about leaks under Windows, SIGNALS that we
> have m-leaks in a program. Moreover, Boost.Test can control this
> function using (to use or not to use).
>
> So I expected that Boost.Test can use this function return code and
> increase errors counter for leaks. If it cannot, this can be
> improvement for the future.

The debug CRT in windows does have memory tracking, but it does not do
a great job at it (can report leaks where there are none). Still
better to use a more dedicated library for that. The release CRT has
no such tracking, but is a great deal faster, and I have seen things
leak in release without leaking in debug for note.


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