Hello everyone,
the following trivial example highlights a memory leak according to MSVC
2010. Does anybody know why this is and how it can be avoided?
// The following three directives are required for MSVC's automatic
memory
// leak detection.
#define _CRTDBG_MAP_ALLOC
#include
#include
#include
int main(int argc, char *argv[])
{
{
using namespace boost::interprocess;
static const char* shMemIdentifier = "MySharedMemory";
struct ShMemCleaner {
ShMemCleaner() {
shared_memory_object::remove(shMemIdentifier); }
~ShMemCleaner()
{shared_memory_object::remove(shMemIdentifier); }
} cleaner;
// Create a new segment with given name and size
managed_shared_memory segment(create_only, shMemIdentifier,
1024);
int* intInShMem = segment.construct<int>("myInt")(2);
segment.destroy<int>("myInt");
}
_CrtDumpMemoryLeaks();
}
Thank you very much!
Best,
Michael