-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Memory Overhead is Too High (10x or more) #1613
Copy link
Copy link
Closed
Labels
kind: enhancement/improvementstate: stalethe issue has not been updated in a while and will be closed automatically soon unless it is updatedthe issue has not been updated in a while and will be closed automatically soon unless it is updated
Description
Activity
Metadata
Metadata
Assignees
Labels
kind: enhancement/improvementstate: stalethe issue has not been updated in a while and will be closed automatically soon unless it is updatedthe issue has not been updated in a while and will be closed automatically soon unless it is updated
Context:
I was parsing a 700MB json file, in Visual Studio 2019. The process took almost 9GB of memory! This at first looks like a 10x overhead.
We all know that std::strings have on the order of 2x overhead, so this doesn't seem to explain it.
All std::TreeNode<basic_string, basic_json> are showing up at taking exactly 140 bytes, which seems excessive. Since they are all the same size, it seems likely the keys are all being allocated much larger than necessary, perhaps. Keys in maps tend to be much shorter than the data that is being mapped to.
Possible solution is to move away from std::map ?
For reference, allocating strings looks like it's about 50% of memory, and treenodes are about 25% of memory in my instance.