AlexeyAB / darknet

YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
http://pjreddie.com/darknet/
Other
21.75k stars 7.96k forks source link

memory leak of yolo_v2_class.hpp #4973

Open Lewis-luo opened 4 years ago

Lewis-luo commented 4 years ago

Hi: Dear friend, I find a question about memory leak in "yolo_v2_class.hpp" head file. In "std::shared_ptr mat_to_image_resize(cv::Mat mat) const" function ,if the parameter "mat.size()" is not equal to "network_size" ,there will be obvious memory leak。In other world,if program executes code “cv::resize(mat, det_mat, network_size);”, a memory leak will occur。I think it might be deep copy。 thanks!

AlexeyAB commented 4 years ago

Are you about this function? https://github.com/AlexeyAB/darknet/blob/b56e8d11cfa4278ad5258eedb5207ae583d16e96/include/yolo_v2_class.hpp#L117-L129

Why do you think that there is a memory leak?

cv::Mat has a destructor that deallocate the memory.