amazon-kinesis-video-streams-webrtc-sdk-c
amazon-kinesis-video-streams-webrtc-sdk-c copied to clipboard
Prefer dynamic allocations over large STATIC arrays
Issue #, if available:
- N/A
What was changed?
- Use dynamically allocated WSS URL
- Use dynamic allocations for singaling payload
- Use required only allocations in LwsApiCalls instead large static arrays
Why was it changed?
- Dynamic SignalingPayload: We end up allocating MAX_SIGNALING_MESSAGE_LEN per signaling message received. For memory constrained devices, this is a huge deal. and would reduce(~couple of 100KBs of) peak memory usage.
- Having exact allocations while doing API calls saves us needing unreasonably high memory needs on stack
How was it changed?
- Provided an option
PREFER_DYNAMIC_ALLOCScmake option. Enabling this, turns dynamic allocations ON instead of large fixed arrays
@sirknightj
- this is comprehensive change to use dynamic allocations instead of huge static arrays.
- https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-c/pull/2140 will be closed in favour of this
I am having the thought of simply keeping dynamic allocations and remove the old code if that makes sense. Saves us from maintaining the switch.
@sirknightj @unicornss would love to get your review on this particular PR.
I believe this is a good change. Previously, the codebase was optimized to avoid dynamic allocations due to the cost impact on many small footprint platforms in favor of the predictable memory footprint. Most platforms do provide a dynamic memory allocators and if a particular platform still has eprom type of memory only, the allocators for the SDK can be overridden to utilize the sub-allocator the SDK provides (AIV heap implementation). There are many samples of this in the tests that validate the memory leakage.