All stacks created by the yaml_document_initialize and yaml_document_add* functions have
a inital size of INITIAL_STACK_SIZE=16.
This results in a huge waste of memory if your average sequence/mapping length is smaller than 16.
For example I have a YAML doc that is 24M on disc. After loading it is 400M.
Most of the time the programmer knows very well, how long a sequence will be.
Thus, the way out would be to add a argument to the above mentioned functions, that specifies the initial capacity.