Boost logo

Boost Users :

From: mike (mboard182_at_[hidden])
Date: 2008-03-21 04:40:37


An extremely simple piece test, containing just one stack-created
object, is causing boost.test to report a memory leak.

I am using boost 1.34.1 compiled in windows using configure, bjam, &
msvc90. I've copied my simple test case illustrating my problem below,
and included the output it produces.

As you can see, boost.test is being used, but the regex is part of
microsoft's tr1. As a note, when I modify it to use boost's regex (with
the commented-out changes seen in code), no such errors were reported.

I'd like to say that obviously the SOLE problem lies in MS' beta tr1
implementation, but this code is so simple I don't get how that would
be. Also, i believe the actual TR1 impl is from dinkumware and is
supposed to be fully release ready (it is just the ms-CLI, etc,
integration which leads to the beta designation)...

Hopefully someone has more insight into this. Also, if someone has any
tips on how to interpret the memory dump boost.test provides, I'd be
interested in learning.

Thanks in advance!

//begin code//
//file dumb_test.cpp
//in a new, default solution w/ precompiled headers turned off,
//all msvc files removed, and include_path += $(boost_root)
//lib_path += $(boost_root)/stage/lib added

#include <boost/test/unit_test.hpp>
#include <regex>
//#include <boost/tr1/tr1/regex>

using boost::unit_test_framework::test_suite;
using std::tr1::regex;
//using boost::regex

void dumb_test(){
   regex rgx("");
   //regex rgx("foo");//boost doesn't like empty rgx str
}

test_suite* init_unit_test_suite(int, char** const){
   test_suite* suite = BOOST_TEST_SUITE("Core Tests");
   suite->add(BOOST_TEST_CASE(&dumb_test));
   return suite;
}
//end code//

//begin output//
Running 1 test case...

*** No errors detected
Detected memory leaks! //with boost::regex no mem leaks...
Dumping objects ->
{208} normal block at 0x00347DD8, 20 bytes long.
Data: <p-J > 70 2D 4A 00 15 00 00 00 00 00 00 00 00 00 00 00
{207} normal block at 0x00347D90, 24 bytes long.
Data: <|-J }4 > 7C 2D 4A 00 0E 00 00 00 00 00 00 00 D8 7D 34 00
{206} normal block at 0x00347D48, 24 bytes long.
Data: < -J }4 > 88 2D 4A 00 0D 00 00 00 00 00 00 00 90 7D 34 00
{205} normal block at 0x00347CF8, 32 bytes long.
Data: <p-J H}4 > 70 2D 4A 00 14 00 00 00 00 00 00 00 48 7D 34 00
Object dump complete.
//end output//


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