Boost logo

Boost Users :

From: Gennadiy Rozental (gennadiy.rozental_at_[hidden])
Date: 2006-04-12 13:33:37


Sorry, for delay response. I've been extremely busy lately.

> We use Boost.Test extensively as our unit test framework. Recently,
> we introduced some code to check for memory leaks. Each test case is
> expected to release all the memory it allocates (i.e. fixtures and
> what not). However, we observe that several of our test cases appear
> to leak memory when in fact they don't. For instance, a memory leak
> check when main() exits reveals no leaks, even though leaks were
> "found" in several test cases. Our observation is that the apparent
> leaks appear and disappear as we modify the test code.
>
> Scrutinizing the code has revealed that adding a BOOST_REQUIRE(true)
> here and there in the problematic test cases can make this problem go
> away. Is it at all possible that Boost.Test somehow allocates memory
> during a test case run, say for logging or other purpose, and doesn't
> release it before the test case ends?

I found similar issues when designed exception safety testing facilities. I
tried to minimize an amount of dynamically allocated memory with Boost.Test
code. Also I am using guard that tell me when I enter/leave Boost.Test code
and stop/start recording memory allocations. It's still not 100%
bulletproof. It's possible that some static/global variables access from
within test case may cause memory allocation. You will need to deal with it
in case by case level.
 Try to wrap Boost.Test tools with your guards.

Gennadiy


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