OpenCV ?false? memory leak in VisualStudio

asked 2019-03-12 06:24:06 -0600

updated 2019-03-12 06:26:50 -0600

Maybe this is not a true memory leak but it must be worrisome to some developers. I have seen similar posts to this around the web.

image description

My most recent experience is with wxWidgets and OpenCV 4.0.0 The single line below that declares a simple Mat makes the difference between VS detecting a memory leak or not. I have tried several suggestions including delayed dll loading for OpenCV dlls, freeing up a mutex in core/system.cpp but no luck so far.

Is this really a memory leak? Any suggestions??

// wxWidgets_OpenCV_LeakTest.cpp
#include <wx/wx.h>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
using namespace cv;
class MyApp : public wxApp
{
public:
    virtual bool OnInit() {
        Mat m(Size(32, 32), CV_8UC1, Scalar(200));
        wxFrame *frame = new wxFrame(NULL, wxID_ANY, "Hello World");
        frame->Show(true);
        return true;
    }
};

wxIMPLEMENT_APP(MyApp);
Detected memory leaks!
Dumping objects ->
{12828} normal block at 0x0000000000516580, 12 bytes long.
 Data: <opencvtrace> 4F 70 65 6E 43 56 54 72 61 63 65 00 
{12827} normal block at 0x0000000000552890, 48 bytes long.
 Data: <         eQ     > 01 00 00 00 CD CD CD CD 80 65 51 00 00 00 00 00 
{12826} normal block at 0x0000000000555E10, 256 bytes long.
 Data: <                > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD 

edit retag flag offensive close merge delete