Friday, 20 May 2011
Developer Journal 84 - On Boost Serialization
I've decided to stick with serializing vectors of random floats with only two decimal places.
Now I'm having an error when I serialize a synapse.
Switching from normal shared pointers to serialization shared pointers.
Still not working.
The crash happens after I serialize about 3996 synapses and then do the next set.
Switched to serialization shared_pointers in class obj.
class Neuron, switched to serialization pointer and vector
class NeuronGroup, switched to serialization pointer and vector
class Brain, switched to serialization pointer and vector
class Robot, switched to serialization pointer and vector
class SimData, switched to serialization pointer
Disabling serialization of class Synapse in class Neuron.
Crash occurs in class Neuron.
Disabling serialization of class Neuron in class NeuronGroup.
Strange. NeuronGroup is still crashing.
I disabled serialization of class Obj in class NeuronGroup.
The crash is now in class Neuron from class Brain.
I disabled serialization of class Obj in class Neuron.
Crash is in now class Brain.
For some reason serialization is happening twice in class Brain even though there is only 1 robot.
For some reason serialization of class Robot is happening twice even though there is only 1 robot.
A while back I was trying to understand the serialization process better. I needed to find out whether when you load an object you get a new object. Yep you do. Memory address before loading 0x20c2890 and after 0x46620c8.
So dumb. Of course serialization happens twice. I rigged a key to do a save and then a load. Another mystery down.
Still not clear why there is a crash in class Brain upon load.
The current crash is when I try to load a vector of smart pointers to Neuron objects in the Brain object.
The crash probably happens because I disable serialization of the base class in class Neuron.
I enabled serialization of base class Obj in class Neuron and NeuronGroup but a crash occurred when I loaded NeuronGroup.
Specifically, when I loaded the output neuron group.
Analyzing what in class NeuronGroup is causing the crash.
Yep, the crash is coming from class NeuronGroup and then Obj.
Disabled code inside Obj serialization function.
In class NeuronGroup I inherited from Obj which was a typedef of class gobject. Changing from Obj to gobject. No luck.
Disabling serialization of output neuron group in class Brain.
Disabling serialization of vector of pointers to all neuron groups.
Crash in vector of pointers to all neurons.
What I'm worried about is that there are some cyclic pointers. For example in class Neuron there are pointers to class Synapse and vice versa.
Crash in vector pointers to all synapses.
Disabling serialization of vector of pointers to all synapses.
Worked. Now to slowly enable things again.
Trying to figure out what in class Synapse is causing the crash.
In class Synapse, the gobject is causing the crash but I don't know how to fix it.
I should switch between normal and serialization versions of pointers and containers by using a macro.
Labels: developer journal