OpenCV memory leak with wxwidgets

I found what I was looking for in the old forum, but there is no answer.

In this link is a minimal example, which displays the error. Anyone know anything about this and how to fix it?

that is a memory leak in user code that purely relates to wxWidgets. that individual is newing something and then throwing the pointer away.

it has nothing at all to do with OpenCV.

if you have a question, ask it, but remember to present a MRE (minimal reproducible example, like on Stack Overflow). and you can be sure that a mere “valgrind said something” will get no attention. valgrind complains whenever it’s in doubt. it’s not smart enough to figure out some programs are actually okay. and that is precisely the reason “valgrind said something” is unacceptable as a bug report, and incredibly tedious as a forum thread.

The problem is that if you comment out the Mat line in the example above, there is no memory leak because wxwidgets automatically clears the pointer to wxFrame. Only if the cv::Mat line is there does the memory leak occur.
So what is wrong…?

the Mat will be properly cleaned up at the end of the scope. that much is sure. valgrind loves to complain but OpenCV’s Mat code has been checked manually.

feel free to browse “valgrind” issues here, especially the “invalid tracker” and “wontfix” ones: Issues · opencv/opencv · GitHub

you’ll note that Intel developers (they drive OpenCV development) may use valgrind, but they don’t blindly believe everything it says. see this comment: