aitrack
aitrack copied to clipboard
memory leak and incorrect usage of member data
Not a crashing bug, but you are not using C/C++ correctly. Just trying to get AITrack build on my machine, to try and detect why it crashes. But I am missing OpenCV includes.. But thats another story..
Why is the member data a pointer to an array? Is it handed over to another class, which takes ownership?
aitrack/AITracker/src/data.h double* .. data.cpp rotation = new double[3]{ 0,0,0 }; translation = new double[3]{ 0,0,0 }; face_coords = new int[4]{ 0,0,0,0 };
This data is never freed in destructor
D:\Data.W10\Downloads\IHC_Cam\aitrack-0.6.4-alpha\Client\src\presenter\presenter.cpp(167): FaceData d = FaceData(); The member data is copied, but only the pointer will be copied, making both instances look at the same pointed data.
D:\Data.W10\Downloads\IHC_Cam\aitrack-0.6.4-alpha\Client\src\presenter\presenter.h(22): FaceData face_data; this doesn't seem to be used.
- Yes. Kind of legacy, but actually it's handed to the filters which soften the noise (filters.cpp/h). When I started making that target the idea was to be more "modular". I didn't want to couple signal postprocessing with FaceData.
- Yeah, you're right. It should be changed to std::make_shared.
- and 4. Yeah, local variable inside the main loop should be changed by the member one.
Will you make a PR with the changes? :)
Does last version still crash for you? Could you give more details?