Boost logo

Boost :

From: Tom Titchener (Tom.Titchener_at_[hidden])
Date: 2006-12-22 14:19:31

I always get the memory leak trace at the end of this post when I run a trivial application that uses boost threads (source below).

I'm compiling with multi-threaded debug dll (/MDd).

I'm building a console app.

It's on win32/xpsp2 with vc8.

I haven't found any thread shutdown code to run in the boost threads documentation.

Have I missed another compiler or linker option?

I'd really like to use leak detection so I know I'm not losing memory in my own code.


Tom Titchener

#include <crtdbg.h>
#include <stdio.h>
#include <iostream>
#include <boost/thread.hpp>

using namespace std;

void CRTSetup(void) {
      _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG));
      _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG));
      _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE );
      _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDOUT );
      _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE );
      _CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDOUT );
      _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );
      _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDOUT );
void dummy(void) {
      cerr << "dummy" << endl;
void main() {
      boost::thread t(dummy);

Detected memory leaks!
Dumping objects ->
{145} normal block at 0x003575D8, 24 bytes long.
 Data: < < > 00 3C 15 00 FF FF FF FF 00 00 00 00 00 00 00 00
{144} normal block at 0x003575A0, 8 bytes long.
 Data: < u5 > D8 75 35 00 01 CD CD CD
Object dump complete.

Boost list run by bdawes at, gregod at, cpdaniel at, john at