Boost logo

Boost Users :

Subject: Re: [Boost-users] managed_shared_memory memory leak(?)
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2012-04-29 18:37:27


El 28/04/2012 14:16, Michael Herrmann escribió:
> Dear Ion,
>
> thank you for your reply. I should have said, sorry, that I am using
> Boost 1.49.0. I can see that such singletons would show up as memory
> leaks. In your example, already including
> boost/interprocess/managed_shared_memory.hpp seems to lead to the
> creation of some singletons that are falsely reported as memory leaks.
> However, there seems to be more than just these singletons, that is
> additionally created when managed_shared_memory::construct is actually
> used. Please consider the following example:

In trunk code singletons are created lazily (after main is entered) in
some platforms. In Boost 1.49 (at least in Visual 7.1) your example does
not detect any leak (_CrtMemDifference returns false).

For singletons created on demand (trunk code), you can change the
LazyInit template parameter to "false" in Interprocess code when
intermodule_singleton, windows_intermodule_singleton,
portable_intermodule_singleton classes are used (e.g. "get_bootstamp" in
tmp_dir_helpers.hpp). This will force singleton creation before main starts.

Best,

Ion

PD: FIIW, as singletons have many problems regarding destruction order,
I'm experimenting with the "Phoenix Singleton" approach these days,
using std::atexit to register singleton destruction. If this works, I
think Lazily created phoenix-singletons will be the default in Interprocess.


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