Azure-Kinect-Sensor-SDK
Azure-Kinect-Sensor-SDK copied to clipboard
K4A_DECLARE_CONTEXT handle macro causes memory leak for cpp objects
K4A_DECLARE_CONTEXT uses malloc and free for allocating/deallocating wrapper context. If there is any cpp objects inside the context, it doesn't call their constructor and destructor properly.
k4a_record_context_t and k4a_playback_context_t are two contexts that have this memory leak issue now.
The macro was only designed for usage with C 😞
@wes-b and I talked and agreed we should either make this work with constructed/destructed objects in C++, or prevent the macro from being invoked from C++. Since we need to use it in existing C++ code, we might as well support that, so Wes is working on a change now.