1
votes

I am writing real time data to boost shared memory. Initially I was using this every time I want to access the shm:

boost::interprocess::managed_shared_memory  segment(boost::interprocess::open_or_create, "MySharedMemory",20000000);

On debug mode I found out that this call always throws this exception:

First-chance exception at 0x00007FFA30BB95FC in testerud.exe: Microsoft C++ exception: boost::interprocess::interprocess_exception at memory location 0x000000000550E1C0.

But I was able to open and push my data to shared memory. I found a turn around to this problem. I created another function just to open_or create at the start of the process and then used open_only to write every time. There was no exception.

I am curious about the reason behind this.

1
"On debug mode I found out that this call always throws this exception" - how is the frequency relevant if you state it always fails? - sehe
Also, why open the segment every time if there's no other threads/processes anyways? Just keep the segment opened. Otherwise "realtime" will soon be a nice way to say "dog slow" - sehe
yes its not relevant here. i will remove it. Thanks. - PrimeOfKnights
I am closing it because I have an other application wich might access and dump the data. - PrimeOfKnights
That's gonna be the cause. Good work! (Oh, aha I thought you meant closing the question, you might as well accept the existing answer, I suppose) - sehe

1 Answers

1
votes

From boost docs:

Managed memory segments also offer the possibility to iterate through constructed named and unique objects for debugging purposes. Caution: this iteration is not thread-safe so the user should make sure that no other thread is manipulating named or unique indexes (creating, erasing, reserving...) in the segment. Other operations not involving indexes can be concurrently executed (raw memory allocation/deallocations, for example).