c++boostshared-memoryboost-interprocess

What is the difference between boost's "windows_shared_memory" and boost's "managed_windows_shared_memory"?


Boost provides several types of shared memory. Amongst them, windows_shared_memory uses Windows' own underlying shared memory capabilities and is therefore platform specific and has some specificities compared to other shared memories (POSIX compatible ones).

It is described here in the documentation.

However, in this other documentation page, the managed_windows_shared_memory is described. Neither mentions the other one's existence.

What is the difference between these two shared memory implementations ?

It looks to me that they both have the same behaviour according to the documentation. Are they just the same mechanism that just displays two different interfaces to use them ?

The includes containing the two implementations :

// The first implementation has to be included here
#include <boost/interprocess/windows_shared_memory.hpp>

// The second implantation has to be included here
#include <boost/interprocess/managed_windows_shared_memory.hpp>

Solution

  • The word "managed" in boost distinguishes several class interface families, not just windows shared memory. The non-"managed" versions are more direct and minimal, supplying just what is needed for low-level operation. The "managed" versions are typically built atop the non-"managed", but also include more boost template magic to give a safer, higher-level interface. Generally prefer "managed" versions because they do more for you.