New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory optimization for embedded devices #1643
Comments
mdamle
added a commit
to mdamle/rapidjson
that referenced
this issue
Feb 20, 2020
This change comes up with compile time pre-processor directives to tune the behavior of rapidjson wrt memory consumption. The idea is to allow each module using this library to choose the right defaults based on how it consumes memory and what performance it expects. 1. RAPIDJSON_USE_CRTALLOCATOR: If defined allows you to choose CrtAllocator over MemoryPoolAllocator. If it is not defined, chooses MemoryPoolAllocator by default. 3. RAPIDJSON_VALUE_DEFAULT_OBJECT_CAPACITY and RAPIDJSON_VALUE_DEFAULT_ARRAY_CAPACITY: If defined and set to a value, uses that value for default number of objects/array elements to be pre-allocated. If not defined, uses value of 16: the current default. Verified that all tests pass.
mdamle
added a commit
to mdamle/rapidjson
that referenced
this issue
Feb 20, 2020
This change comes up with compile time pre-processor directives to tune the behavior of rapidjson wrt memory consumption. The idea is to allow each module using this library to choose the right defaults based on how it consumes memory and what performance it expects. 1. RAPIDJSON_DEFAULT_ALLOCATOR: If defined allows you to choose CrtAllocator over MemoryPoolAllocator. If it is not defined, chooses MemoryPoolAllocator by default. 2. RAPIDJSON_VALUE_DEFAULT_OBJECT_CAPACITY and RAPIDJSON_VALUE_DEFAULT_ARRAY_CAPACITY: If defined and set to a value, uses that value for default number of objects/array elements to be pre-allocated. If not defined, uses value of 16: the current default. Verified that all tests pass.
mdamle
added a commit
to mdamle/rapidjson
that referenced
this issue
Feb 21, 2020
This change comes up with compile time pre-processor directives to tune the behavior of rapidjson wrt memory consumption. The idea is to allow each module using this library to choose the right defaults based on how it consumes memory and what performance it expects. 1. RAPIDJSON_DEFAULT_ALLOCATOR: If defined allows you to choose CrtAllocator over MemoryPoolAllocator. If it is not defined, chooses MemoryPoolAllocator by default. 2. RAPIDJSON_VALUE_DEFAULT_OBJECT_CAPACITY and RAPIDJSON_VALUE_DEFAULT_ARRAY_CAPACITY: If defined and set to a value, uses that value for default number of objects/array elements to be pre-allocated. If not defined, uses value of 16: the current default. Verified that all tests pass.
mdamle
added a commit
to mdamle/rapidjson
that referenced
this issue
Feb 21, 2020
This change comes up with compile time pre-processor directives to tune the behavior of rapidjson wrt memory consumption. The idea is to allow each module using this library to choose the right defaults based on how it consumes memory and what performance it expects. 1. RAPIDJSON_DEFAULT_ALLOCATOR: If defined allows you to choose CrtAllocator over MemoryPoolAllocator. If it is not defined, chooses MemoryPoolAllocator by default. 2. RAPIDJSON_VALUE_DEFAULT_OBJECT_CAPACITY and RAPIDJSON_VALUE_DEFAULT_ARRAY_CAPACITY: If defined and set to a value, uses that value for default number of objects/array elements to be pre-allocated. If not defined, uses value of 16: the current default. Verified that all tests pass.
mdamle
added a commit
to mdamle/rapidjson
that referenced
this issue
Feb 25, 2020
This change comes up with compile time pre-processor directives to tune the behavior of rapidjson wrt memory consumption. The idea is to allow each module using this library to choose the right defaults based on how it consumes memory and what performance it expects. 1. RAPIDJSON_DEFAULT_ALLOCATOR: If defined allows you to choose CrtAllocator over MemoryPoolAllocator. If it is not defined, chooses MemoryPoolAllocator by default. 2. RAPIDJSON_DEFAULT_STACK_ALLOCATOR: If defined allows you to choose MemoryPoolAllocator over CrtAllocator. If it is not defined, chooses CrtAllocator by default. 3. RAPIDJSON_VALUE_DEFAULT_OBJECT_CAPACITY and RAPIDJSON_VALUE_DEFAULT_ARRAY_CAPACITY: If defined and set to a value, uses that value for default number of objects/array elements to be pre-allocated. If not defined, uses value of 16: the current default. Verified that all tests pass.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For #1:
On embedded platforms with limited memory CrtAllocator can be a good choice. You can use CrtAllocator in a module today by explicitly creating your own typedef:
"
typedef GenericValue<UTF8<>, CrtAllocator> Value
"
This is cumbersome when working on a platform with multiple modules using rapidjson since each module has to have the same definition of rapidjson::Value so as to interoperate.
One solution is to create a pre-processor directive (#define RAPIDJSON_USE_CRTALLOCATOR) such that all modules that want to use CrtAllocator can do so at compile time without having to explicitly typedef them individually.
For #2:
On the same lines as this commit: 6f58746 allow default object and array capacity to be configured using pre-processor directives.
The text was updated successfully, but these errors were encountered: