I know that the CrtAllocator
is the C runtime allocator and uses malloc
/realloc
/free
, and I know that the MemoryPoolAllocator
is the default allocator and allocates memory sequentially
.
I don't understand why the MemoryPoolAllocator
is considered more efficient than the CrtAllocator
. Does the MemoryPoolAllocator
just default allocate a large block of memory and just add entries into it each time Parse()
is called? If so, does that mean the CrtAllocator
calls malloc
for every new Parse()
?
The docs indicate this for the CrtAllocator
: When there is a lot of add and remove operations, this allocator may be preferred. But this allocator is far less efficient than MemoryPoolAllocator.
but it does not explain why it is better for a lot of adds/remove vs the MemoryPoolAllocator
or why/how it is far less efficient than MemoryPoolAllocator
.
The primary use case I care about is quickly parsing JSON responses from the Web. My plan is to just allocate a large buffer and reuse it for every response. I think I can just use ParseInsitu()
and clear the buffer every time.
Does it matter which Allocator I use for this use-case?