Re: [Boost-users] [Test] How to treat memory leaks as errors?

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. WBR, Vasily P.S. _CrtDumpMemoryLeaks?

2009/9/20 Василий Старостин
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.

Василий Старостин wrote:
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 problem is that this function is not invoked till after testing framework is done. in fact I do not invoke it at all. It is invoked by the CRT once program execution is completed. Running this function earlier most probably will produce huge number of false positives. Gennadiy

On Sat, Sep 26, 2009 at 5:24 PM, Gennadiy Rozental
Василий Старостин wrote:
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 problem is that this function is not invoked till after testing framework is done. in fact I do not invoke it at all. It is invoked by the CRT once program execution is completed.
Running this function earlier most probably will produce huge number of false positives.
For note, the google memory tracker allows you to even partition segments of your program off, letting you test for memory leaks just from those sections and so forth, it is very powerful, as well as multi-platform.

OvermindDL1 wrote:
For note, the google memory tracker allows you to even partition segments of your program off, letting you test for memory leaks just from those sections and so forth, it is very powerful, as well as multi-platform.
Can you point to docs/download location? How portable is it? At what point it performs instrumentation? Gennadiy

On Sun, Sep 27, 2009 at 12:01 AM, Gennadiy Rozental
OvermindDL1 wrote:
For note, the google memory tracker allows you to even partition segments of your program off, letting you test for memory leaks just from those sections and so forth, it is very powerful, as well as multi-platform.
Can you point to docs/download location? How portable is it? At what point it performs instrumentation?
Main site: http://goog-perftools.sourceforge.net/ The memory allocator and leak checker is very portable as I recall, the profiler is not as portable (but you do not need it from the sounds of it), but they are working on it. This is what Google actually uses in their own products and servers, very well tested. It will report results either at program end, or at any specific time you specify, as stated, it is very powerful, and very easy to use, I have been quite happy with it, and the memory allocator has speed up some of my memory intensive programs by a surprising amount. The code is actually very generic, it could actually, quite easily, become a boost library (if Google would ever offer it up as such), maybe with some namespace changes and such though.

On Sun, Sep 27, 2009 at 1:37 AM, OvermindDL1
On Sun, Sep 27, 2009 at 12:01 AM, Gennadiy Rozental
wrote: OvermindDL1 wrote:
For note, the google memory tracker allows you to even partition segments of your program off, letting you test for memory leaks just from those sections and so forth, it is very powerful, as well as multi-platform.
Can you point to docs/download location? How portable is it? At what point it performs instrumentation?
Main site: http://goog-perftools.sourceforge.net/
The memory allocator and leak checker is very portable as I recall, the profiler is not as portable (but you do not need it from the sounds of it), but they are working on it. This is what Google actually uses in their own products and servers, very well tested.
It will report results either at program end, or at any specific time you specify, as stated, it is very powerful, and very easy to use, I have been quite happy with it, and the memory allocator has speed up some of my memory intensive programs by a surprising amount.
The code is actually very generic, it could actually, quite easily, become a boost library (if Google would ever offer it up as such), maybe with some namespace changes and such though.
Correction, now located here: http://code.google.com/p/google-perftools/
participants (3)
-
Gennadiy Rozental
-
OvermindDL1
-
Василий Старостин