Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-08-29 14:47:51


Elisha Berns wrote:

[...]

> Secondly, how many microseconds does it actually take to free the
> memory allocated by the threadmon mutex?

It's not a question of microseconds. The "thread safe singleton" pattern
solves the initialization order problem. You want a particular object to be
available for the lifetime of the program, as if it was initialized before
everything else and destroyed after everything else.

C++ doesn't guarantee a particular initialization order for file scope
objects in different translation units, so we have to resort to local
statics or call_once.

I haven't studied the threadmon code in detail, though. It might be possible
to destroy the threadmon mutex safely at some point during shutdown.

My original point was that this is a legitimate coding idiom and not a
memory leak. It might be a resource leak on Windows 9x; I no longer keep
Win9x around so I can't check.


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