|
Boost Users : |
From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2007-01-20 08:43:46
Pete,
I yesterday faced the bug as well. Funny thing is, that even Boost Unit
Testing Framework reports the memory leak. It is really simple to reproduce:
struct some_thread_function
{
void operator()()const
{
//really simple code here, to make some calculations in a
thread ;)
}
}
void test_threading_lib()
{
{
boost::thread_group grp;
for(int i=0; i<100; ++i) //create 100 threads
grp.create_thread(some_thread_function());
grp.join_all();
}
BOOST_MESSAGE( "Memory leak should be identified..." );
}
This already produces a mem leak in unit testing framework:
test_suite* init_unit_test_suite( int argc, char* argv[] )
{
test_suite* test = BOOST_TEST_SUITE( "Test for memory leak" );
test->add( BOOST_TEST_CASE( &test_threading_lib ) );
return test;
}
Thanks,
Ovanes
-----Original Message-----
From: pete_at_[hidden] [mailto:pete_at_[hidden]]
Sent: Friday, January 19, 2007 11:15 PM
To: boost-users_at_[hidden]
Subject: Re: [Boost-users] Does boost::thread_group::create_thread
havememory leak?
On Fri, Jan 19, 2007 at 11:26:50AM +0100, Roland Schwarz wrote:
> pete_at_[hidden] wrote:
> > I've been trying to track down memory leak being reported by valgrind.
> <snipped>
> > /usr/lib/libboost_thread-mt.so.1.33.1)
>
> Version 1.33 is know to have a memory leak, but I am surprised that it
> shows up on linux.
> Can you repeat this with the 1.34 CVS version?
I complied against the latest cvs version and still got the leak.
boost::thread_group::create_thread(boost::function0<void,
std::allocator<boost::function_base> > const&) (thread.cpp:338)
It appears to come from this line in boost/lib/src/pthread.cpp:
std::auto_ptr<thread> thrd(new thread(threadfunc));
Could it be that the leak is being created by using the tmp object in the
thread creation? I've read advise about NOT doing that?
I realized after reading your email again that 1.34 is what you specified,
but I used 1.35. Would that be a problem?
Thanks,
Pete
_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
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