Memory leaks compiling C++ MFC App in debug mode

Hi guys,

i’m using OpenCV in a very simple C++ MFC application that i need to create with the following settings:

System information (version):

OpenCV => 4.5.4 and 4.3.0 Tested
Operating System / Platform => Windows 10 Pro
Compiler => : Visual studio 2019 pro

When i try to execute application in debug mode, it closes with a lot of (false?) memory leaks as shown below:

Detected memory leaks!
Dumping objects ->
{1455} normal block at 0x0000016A80306860, 16 bytes long.
 Data: <                > D0 0B 16 C7 FE 7F 00 00 02 00 00 00 CD CD CD CD 
{977} normal block at 0x0000016A802F4C10, 16 bytes long.
 Data: <                > 10 0C 16 C7 FE 7F 00 00 01 00 00 00 CD CD CD CD 
{845} normal block at 0x0000016A802C3CE0, 80 bytes long.
 Data: <        `       > 02 01 00 00 CD CD CD CD 60 BC 87 C7 FE 7F 00 00 
{769} normal block at 0x0000016A802DCE50, 8 bytes long.
 Data: <h       > 68 D4 0D C7 FE 7F 00 00 
{514} normal block at 0x0000016A802C01A0, 64 bytes long.
 Data: <                > 01 00 CD CD 00 00 00 00 00 00 00 00 00 00 00 00 
{469} normal block at 0x0000016A802C4770, 40 bytes long.
 Data: < B, j    B, j   > A0 42 2C 80 6A 01 00 00 A0 42 2C 80 6A 01 00 00 
{468} normal block at 0x0000016A802C4690, 40 bytes long.
 Data: < F, j    F, j   > 20 46 2C 80 6A 01 00 00 20 46 2C 80 6A 01 00 00 
{467} normal block at 0x0000016A802D3BE0, 16 bytes long.
 Data: <0 , j           > 30 06 2C 80 6A 01 00 00 00 00 00 00 00 00 00 00 
{466} normal block at 0x0000016A802C0620, 64 bytes long.
 Data: <  , j     , j   > 20 08 2C 80 6A 01 00 00 20 08 2C 80 6A 01 00 00 

Below a detail of project properties and the content of the OnInitDialog () method implemented:

Project Properties > Configuration Properties > C/C++>General >Additional Include Directories > D:\pencv_build\include\build\include
Project Properties > Configuration Properties > Linker > General > Additional Library Directories > D:\opencv_build\lib\Debug
Project Properties > Configuration Properties > Linker > Input > Additional Dependencies > opencv_core454d.lib;opencv_highgui454d.lib;opencv_imgcodecs454d.lib;opencv_imgproc454d.lib;opencv_videoio454d.lib
Project Properties > Configuration Properties > Linker > Input > Delay Loaded Dlls > opencv_core454d.dll;opencv_highgui454d.dll;opencv_imgcodecs454d.dll;opencv_imgproc454d.dll;opencv_videoio454d.dll
BOOL CMFCApplication1Dlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != nullptr)
	{
		BOOL bNameValid;
		CString strAboutMenu;
		bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
		ASSERT(bNameValid);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	Mat image1;

	image1 = imread("C:/Users/domen/Desktop/TestImg.jpg");

	// Check for failure
	if (!image1.empty())
	{
		String windowName = "ExampleImg"; //Name of the window

		namedWindow(windowName); // Create a window
		imshow(windowName, image1); // Show our image inside the created window.
		waitKey(0); // Wait for any keystroke in the window
		destroyWindow(windowName); //destroy the created window
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	// TODO: Add extra initialization here

	return TRUE;  // return TRUE  unless you set the focus to a control
}

As sugested by other users, i’ve tried to apply the method that using delay loaded DLL, but it does not work.
How can I fix this problem?

Thanks in advance.

I also have several memory leaks just loading opencv 4 in debug mode. Could someone give me any suggestion on how to avoid them? They are very annoying because they let me distract from real application memory leaks.
thank you