Yes, this is a known bug resulting from the fact that I developed the
shutdown code on Linux rather than Windows -- this bug only exists on
Windows.  It's still not a real leak unless you are dynamically loading and
unloading the protobuf library as a DLL.  In any case, this has been fixed
in SVN and the fix will be in the next release.

On Mon, Jul 6, 2009 at 9:05 AM, Alex Black <> wrote:

> I'm using a memory leak detection tool (ms crtdbg).  It runs at the
> end of the program (after main has exited), and is reporting 7 40byte
> leaks, each of which corresponds to a new call in GoogleOnceType,
> they're each one of these two:
> GoogleOnceType::GoogleOnceType() {
>  // internal_ may be non-NULL if Init() was already called.
>  if (internal_ == NULL) internal_ = new
> void GoogleOnceType::Init(void (*init_func)()) {
>  // internal_ may be NULL if we're still in dynamic initialization
> and the
>  // constructor has not been called yet.  As mentioned in once.h, we
> assume
>  // that the program is still single-threaded at this time, and
> therefore it
>  // should be safe to initialize internal_ like so.
>  if (internal_ == NULL) internal_ = new GoogleOnceInternal;
>  EnterCriticalSection(&internal_->critical_section);
>  if (!initialized_) {
>    init_func();
>    initialized_ = true;
>  }
>  LeaveCriticalSection(&internal_->critical_section);
> }
> I *am* calling google::protobuf::ShutdownProtobufLibrary(); at the end
> of my Main routine (i.e. before the memory leak detection is done).
> Are these real leaks? Is there any way I can avoid seeing them as
> leaks (it'd be nice to have 0 leaks... :)
> - Alex
> >

You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

Reply via email to