Boost logo

Boost :

From: Michael Glassford (glassfordm_at_[hidden])
Date: 2004-01-19 17:42:39


Roland wrote:
> 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):
>

<snipped example>

First of all, if I understand correctly, in your example you put the
_CrtDumpMemoryLeaks() call too early: since it simply lists all blocks
that are allocated at the time when it is called, it should normally
be called at a point where all memory ought to have been freed; so the
beginning of the main() function seems to be the wrong place for it. A
better way would be the end of main() (though this is still too early
in that static objects haven't been destroyed and released their
memory yet); perhaps even better is to call

    CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF |
_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG))

which sets a flag telling the memory allocator to check for leaks on
exit. However, even with these methods I still see "leaks" reported. I
have yet to determine which of them are real problems and which are
valid behavior, but will look into it.

Mike


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk