Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the memory overhead for boost::property_tree::ptree

I have found that boost::property_tree::ptree has an enormous memory overhead. My estimate is that an empty ptree is about 150 bytes, and, any entry put in a ptree adds at least another 150 bytes. This makes it unusable for us for trees containing thousands of entries.

Is my estimation off? Is there some way to keep the overhead low?

like image 920
silvermangb Avatar asked May 25 '13 02:05

silvermangb


1 Answers

Boost.PropertyTree is basically not a fast or lightweight parser.
It focuses on providing high layer convenience and functionalities, so it is not built to be efficient, I guess.

You could see this thread on boost mailing list for a similar question.

I'd suggest that an alternative of Boost.PropertyTree might be either:

  • a SAX parser -- this is an another approach for XML parsing. It's like an opposite of DOM parser; it parses XML nodes one by one. Usually, the "memory allocation for entire file at the begginning" occurs in a DOM parser, but it won't occur on SAX parsers.
  • an allocator-customizable parser + user defined memory pool -- you could configure the allocator of such parser to point the stable memory pool. It could simply be a large buffer of pre-allocated memory, a fragmentation-aware pool, or even a memory-mapped file, etc...
like image 118
saki7 Avatar answered Oct 02 '22 19:10

saki7