Boost logo

Boost Users :

Subject: [Boost-users] Allocation/deallocations during boost serialization (tracking help?)
From: miles_c_at_[hidden]
Date: 2014-08-12 14:55:24


Hello all!

I'm hoping I can get some advice regarding boost serialization:

Basically, I'm dealing with the tracking problem described here:  http://www.boost.org/doc/libs/1_35_0/libs/serialization/doc/special.html#objecttracking.  Normally it seems that the solution is the reset_object_address function, but my object is not really being moved from one point in the memory space to another point in the memory space, but instead being moved out of the memory space altogether (currently it's being stored in a file via a different archive, but in theory this problem would occur if the item was also being stored in a database, being sent somewhere over the network, etc).

Basically the order of events goes like this:

1.  Memory for my object is allocated
2.  Object is read in from archive
3.  Data is transferred out of the memory space.
4.  Memory for my object is deallocated
5.  Memory for next object is allocated.  Malloc chooses the same location for this new object.
6.  Object is read in from archive, but incorrectly because the receiving locations have the same memory address.

What I would really like is "3.5:  Tell the serialization engine to not worry about me any more".  Like I said "reset_object_address" would normally save me here, but I don't have a second location in memory to send it to.

Is there any technique to let me do what I want to do?  Currently the problem is solved by setting the object trait to "track_never", but this seems sort of like fixing a pothole by closing the road.

I'd appreciate any help you can give.

Cheers!
Miles.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net