Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Weird memory leaks in MFC

I have a problem with weird memory leaks. When I create simple MFC Dialog based application and add some Opencv code I get memory leaks warning even the OpenCV code is never executed. (OpenCV 3.1, VS11)

I have added only this:

    #include <opencv2/core.hpp>
    ...    
    void OCVLeakTestDlg::OnBnClickedButton1()
    {
             cv::Mat m1(100,100,CV_8U);
    }
    ...

And the result is:

Detected memory leaks!
Dumping objects ->
{84} normal block at 0x003A58A0, 28 bytes long.
 Data: < X:             > D8 58 3A 00 FF FF FF FF 00 00 00 00 00 00 00 00 
{83} normal block at 0x003A5860, 4 bytes long.
 Data: < X: > A0 58 3A 00 
Object dump complete.
The program '[4204] OCVLeakTest.exe' has exited with code 0 (0x0).

The code inside OnBnClickedButton1 function is never executed but it causing memory leaks. When I remove this code, it's ok without any memory leaks. I tried everything. Shared DLLs, Static libs, but still the same result. Maybe I forgot some settings, because I build OpenCV by myself.