amazon-kinesis-video-streams-producer-sdk-cpp
amazon-kinesis-video-streams-producer-sdk-cpp copied to clipboard
Fix memory leak in failed DefaultCallbackProvider constructor
Description of changes:
I noticed a leak in memory in our application and was able to trace it to the KVS C++ Producer Library. This situation was mainly occuring when the producer could not reach the internet.
Our application is long-living, and will restart the pipeline with kvssink if it fails very quickly, so in times of internet outage we cycle through instances of kvssink fairly quickly.
As is visible in the graph, at the time this dump was taken, KVS Producer was responsible for 30GB of memory coming from createCurlApiCallbacks. On investigation, I was able trace this back to the DefaultCallbackProvider not freeing memory allocated to PClientCallbacks instance when the constructor failed.
This issue was fixed by transitioning the PClientCallbacks instance to a separate RAII instance that will automatically free when the DefaultCallbackProvider instance goes out of scope.
This change has been running in a test environment with the triggering conditions for 4 days and we have seen the leak resolved.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.