2011/7/28 Nathan Lewis
TONGARI
writes: Generally, you should not deallocate what you didn't allocate by
yourself.It's the container's job to deallocate its elems, and it's your job to destruct the container when you don't need it anymore, like: segment.destroy<ComplexDataVector>("ComplexDataVector");
Lots of good learning points I appreciate the learning opportunity. So is what you are explaining is that one would just pop the elements out of the vector and then they would be deleted when this call is made by the resource that "owns" it and is done with it: segment.destroy<ComplexDataVector>("ComplexDataVector");
Or are you explaining that when the pop is called, the internals of the vector implementation invokes the destruction of the object.
Yes. And the allocation/deallocation is performed by the container, say, ComplexDataVector, when it needs to adjust its internal storage. segment.destroy<...>(...) will destruct the found object and deallocate the memory. It's analog of "delete". I so appreciate your responses, it has been tremendously helpful. Working
with Boost Interprocess has made me think a lot more about the allocation/deallocation process that tends to get abstracted away but is useful in understanding.
HTH