From: Michael Glassford (glassfordm_at_[hidden])
Date: 2004-08-05 11:56:40
"Roland" <roland.schwarz_at_[hidden]> wrote in message
> On Thu, 5 Aug 2004 18:10:10 +0200 (W. Europe Daylight Time) Roland
> > BTW.: while everything seems nice so far I just tried to use the
> > MFC. It turns out that the process / thread init / term need even
some more tweeking.
> > While every destructor is getting called properly the debug
version of MFC still
> > thinks it has discovered a memory leak. Since this will be able to
make a potential
> > user nervous, I am looking to a way to get rid of these messages
> > the correct calling order).
> I am not anymore sure the leak has to do with the calling order. At
least I tracked
> the leak down to somewhere near:
> // Intentional memory "leak"
> // This is the only way to ensure the mutex in the global data
> // structure is available when cleanup handlers are run, since
> // execution order of cleanup handlers is unspecified on any
> // with regards to C++ destructor ordering rules.
> However I do not yet understand fully what is going on. What will I
> expect beeing leaking?
What's being intentionally leaked?
1) The tls slot used by tss (not the same as the one used by
threadmon) is never released.
2) The tss_data_t struct allocated at the beginning of the
init_tss_data() function is also being leaked.
> I am not sure if there are additional leaks from
> Also, isn't the atexit well specified with respect to the global
The cleanup handlers being referred to in the comment are tls cleanup
handlers. It has nothing to do with atexit:
1) The Windows cleanup handlers, when called by DllMain, (probably)
still have the same problem that they used to have tls_callback: they
can be called after constructors. I haven't gotten around to fixing
2) IIUC, with the pthreads cleanup handlers, it is literally
unspecified whether they run before or after C++ destructors because
pthreads is a C-based standard.
3) I'm not sure how the MPThreads cleanup handlers work, but judging
by the comment it is also unspecified whether they run before or after
> Is this MS specific or is this in the standard?
> Could you please help me?
Hope that helps.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk