AIRLegend / aitrack

6DoF Head tracking software
MIT License
1.07k stars 107 forks source link

memory leak and incorrect usage of member data #91

Open Eta76 opened 3 years ago

Eta76 commented 3 years ago

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..

1) 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 };

2) This data is never freed in destructor

3) 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.

4) 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.

AIRLegend commented 3 years ago
  1. 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.
  2. Yeah, you're right. It should be changed to std::make_shared.
  3. 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?