What is the excess memory for boost :: property_tree :: ptree

I found that boost :: property_tree :: ptree has a huge memory overhead. My assessment is that empty ptree is around 150 bytes, and any record placed in ptree adds at least another 150 bytes. This makes it unsuitable for us for trees containing thousands of records.

Does my assessment refuse? Is there a way to keep my overhead low?

+6
source share
1 answer

Boost.PropertyTree is basically not a fast or light parser.
It focuses on providing high-level convenience and functionality, so it is not built to be effective, I think.

You can see this thread on the extended mailing list for a similar question.

I would suggest that the alternative to Boost.PropertyTree could be either:

  • a SAX parser is another approach for parsing XML. This is the opposite of a DOM parser; it parses the XML nodes one by one. Usually the "memory allocation for the entire file at the beginning" occurs in the DOM parser, but this does not happen in SAX parsers.
  • parser + user-defined memory pool allocated using the allocator - you can configure the allocator of such parsing to indicate a stable memory pool. It can be just a large buffer of pre-allocated memory, a fragmentation pool, or even a file with memory mapping, etc.
+1
source

Source: https://habr.com/ru/post/945817/


All Articles