ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> boost
boost
[boost] Boost.Thread : Memory leakage with thread local storage?
by Roland other posts by this author
Jan 14 2004 12:08PM messages near this date
Re: [boost] Becoming a booster | [boost] Re: Re: Boost.Thread : Memory leakage with thread localstorage?
The thread local storage leaks memory on Windows/MSVC6.

Is this a know issue?

Small example (the tss.cpp example amended by leak debugging functions):

#define _CRTDBG_MAP_ALLOC
#include <stdlib.h> 
#include <crtdbg.h> 


#include <boost/thread/thread.hpp> 
#include <boost/thread/tss.hpp> 
#include <cassert> 

boost::thread_specific_ptr<int>  value;

void increment()
{
    int* p = value.get();
    ++*p;
}

void thread_proc()
{
    value.reset(new int(0)); // initialize the thread's storage
    for (int i=0; i<10; ++i)
    {
        increment();
        int* p = value.get();
        assert(*p == i+1);
    }
}

int main(int argc, char* argv[])
{
	_CrtDumpMemoryLeaks();

    boost::thread_group threads;
    for (int i=0; i<5; ++i)
        threads.create_thread(&thread_proc);
    threads.join_all();
}

Debug output window:

Detected memory leaks!
Dumping objects -> 
{51} normal block at 0x002F42D8, 20 bytes long.
 Data: < B/  ,/  B/     >  D8 42 2F 00 88 2C 2F 00 D8 42 2F 00 CD CD CD CD 
{50} normal block at 0x002F2C88, 20 bytes long.
 Data: <                >  00 00 00 00 00 00 00 00 00 00 00 00 CD CD CD CD 
{45} normal block at 0x002F4178, 33 bytes long.
 Data: < C              >  00 43 00 CD CD CD CD CD CD CD CD CD CD CD CD CD 
{44} normal block at 0x002F4110, 40 bytes long.
 Data: < |L             >  14 7C 4C 10 16 00 00 00 00 00 00 00 00 00 00 00 
Object dump complete.

Regards,
Roland


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Thread:
Roland
Michael Glassford
Michael Glassford
Roland
Michael Glassford

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved