[Interprocess] Mapped file destructor
Hello, In my code I open a mapped file (previously created) and I construct an object inside, this object is valid and I can use it. But after the mapped_file has been destroyed my object is not valid anymore. It happens just after the call to the destructor of the mapped file. How can I tell to the Mapped File to do not flush its content when it is destructed? Best regards. Thomas
Thomas d'Erceville escribió:
Hello,
In my code I open a mapped file (previously created) and I construct an object inside, this object is valid and I can use it. But after the mapped_file has been destroyed my object is not valid anymore. It happens just after the call to the destructor of the mapped file.
How can I tell to the Mapped File to do not flush its content when it is destructed?
Sorry the long delay, I've been on holidays. I don't understand your question: when the mapped file is destroyed, the address range is unmapped from the process, so you will get a segmentation fault if you try to access the address of your object. That's how memory mapping works, once you unmap it, that address is garbage. Best, Ion
Best regards.
Thomas
------------------------------------------------------------------------
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Thanks a lot for your answer.
I figured out this RAII pattern behavior a short time after I wrote this
message. Actually I though I have to explicitly "unmap" these addresses.
Best,
Thomas
2009/7/30 Ion Gaztañaga
Thomas d'Erceville escribió:
Hello,
In my code I open a mapped file (previously created) and I construct an object inside, this object is valid and I can use it. But after the mapped_file has been destroyed my object is not valid anymore. It happens just after the call to the destructor of the mapped file.
How can I tell to the Mapped File to do not flush its content when it is destructed?
Sorry the long delay, I've been on holidays.
I don't understand your question: when the mapped file is destroyed, the address range is unmapped from the process, so you will get a segmentation fault if you try to access the address of your object. That's how memory mapping works, once you unmap it, that address is garbage.
Best,
Ion
Best regards.
Thomas
------------------------------------------------------------------------
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Ion Gaztañaga
-
Thomas d'Erceville