[xsde-users] memory management of "variable length" elements

Boris Kolpackov boris at codesynthesis.com
Wed Sep 8 10:40:21 EDT 2010

Hi Ivan,

Ivan Le Lann <ivan.lelann at free.fr> writes:

> I played with XSDe/Hybrid 3.1 and I'm unsurprisingly very happy with it.

I am glad you are enjoying it.

> While I do understand the move against deep copy,
> I see no "non destructive" shallow copy alternative.
> Does anyone know an existing way to handle such "object assembling" 
> with xsde ?

There is currently no support for this. If you need to copy the
var-length object, you need to manually copy its members as well.

The alternative could be to serialize to XML using several parts
instead of one object model thus avoiding copying altogether (here
I assume that the goal of constructing an object from multiple
parts it to eventually write it out to XML).

> So far, the solutions I see would be to either :
> 1) use copy-on-write or shared pointer in containers of some user-listed 
>    VL types.

I think COW or reference counting would be too heavy-weight for XSD/e.
Remember that its primary targets are mobile and embedded systems which
can have only very basic C++ support, without exceptions, etc. Implementing
error handling in COW without exceptions could be challenging. Also the
overhead of storing a counter in each var-length object could be too
high for some memory-constrained systems.

> 2) allow deep copy of some user-listed VL types.

That's on the TODO for the next release. There will be an option to 
request generating of copy constructors/clone functions for var-length


More information about the xsde-users mailing list