Azure-Kinect-Sensor-SDK icon indicating copy to clipboard operation
Azure-Kinect-Sensor-SDK copied to clipboard

K4A_DECLARE_CONTEXT handle macro causes memory leak for cpp objects

Open yijiew opened this issue 7 years ago • 1 comments

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.

yijiew avatar Mar 14 '19 20:03 yijiew

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.

Brent-A avatar Mar 15 '19 20:03 Brent-A