recently I re-came up with an algorithm in an item I wrote before, which was encapsulated into a .h file for calling, but there was a problem when I took it out and used it alone. The culprit of the
problem is the Vector variable. Because of the project integration third-party open source library (opencv), the variable can only use the vector type, and then I first created a vector variable
vector < vector < Point > > contours;
findContours (input, contours, CV_RETR_TREE, CV_CHAIN_APPROX_NONE, Point (0,0));
then call the library findContours function to put the value into the contours variable, and then do some basic queries on the contours variable. When my whole method call is over, there is a problem
as shown in the figure, there was a memory leak at the end of my own function, which also occurred when I tried to clear the vector variable manually. It didn"t work even if I even tried to empty the memory first and then reclaim it.
* contours.clear ();
vector < vector < Point > > (). Swap (contours); *
so I can"t think of how to solve this problem, the use of this variable is necessary, but I don"t know how to deal with this memory space at the end!
in addition, my development tool is from VS2013 to 2017, this algorithm was previously integrated into the MFC framework, and there was no problem.