<h5 dir="auto">System information (version)</h5>

<ul dir="auto">
<li>OpenCV =&gt; 4.2</li>
<li>Operating System / Platform =&gt; Ubuntu 16.04</li>
<li>Compiler =&gt; <g-emoji class="g-emoji" alias="grey_question" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/2754.png">❔</g-emoji></li>
</ul>
<h5 dir="auto">Detailed description</h5>
<p dir="auto">I'm using python bindings for opencv and found a bug with resizing images with 5 channels. It works fine for any other number of channels.<br>
I've also checked previous versions and it works in 4.1.1. So the bug should be very recent</p>

<h5 dir="auto">Steps to reproduce</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import numpy as np
import cv2
arr = np.ones((1200, 1200, 5), dtype=np.uint8)
cv2.resize(arr, (512, 512))"><pre class="notranslate"><code class="notranslate">import numpy as np
import cv2
arr = np.ones((1200, 1200, 5), dtype=np.uint8)
cv2.resize(arr, (512, 512))
</code></pre></div>
<p dir="auto">for me it fails with<br>
<code class="notranslate">double free or corruption (!prev)</code></p>
<h5 dir="auto">System information (version)</h5>

<ul dir="auto">
<li>OpenCV =&gt; 4 (June 2018, version from master)</li>
<li>Operating System / Platform =&gt; Windows 10; 64bit</li>
<li>Compiler =&gt; Visual Studio 2015: v140_xp</li>
</ul>
<h5 dir="auto">Detailed description</h5>
<p dir="auto">When I use the visual studio leak detector: <a href="https://archive.codeplex.com/?p=vld" rel="nofollow">https://archive.codeplex.com/?p=vld</a>, I get tons of memory leaks for a very simple command line application using latest OpenCV, especially the dnn module.<br>
Actually I get the same memory leaks without the vld-extension but same code within the constructor of a frame with wxWidgets 3.0. But this is not so simple to reproduce for others (you need wxWidgets), therefore I will post the code of a simple command line program.</p>
<p dir="auto">Actually, I am not quiet sure, if the leak report is correct or if these are "false flags". Any help or comment is appreciated.</p>
<h5 dir="auto">Steps to reproduce</h5>
<div class="highlight highlight-source-c++ notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="#include &quot;StdAfx.h&quot;
#include &lt;opencv2\core.hpp&gt;
#include &lt;opencv2\dnn.hpp&gt;
#include &lt;vld.h&gt; //&lt;-- for memory leak detection, see https://archive.codeplex.com/?p=vld
// entry point for MemoryLeakTestProjectOpenCV4
int main(int /*argc*/, char* /*argv*/[ ])
{
	const int nWidth = 300;
	const int nHeight = 300;
	const std::string sPathToModel = &quot;C:/Projects/SSS-FPCoding/MemoryLeakTestProjectOpenCV4/Debug MD/x64/test.pb&quot;;
	cv::Mat oImage = cv::Mat::ones(cv::Size(nWidth, nHeight), CV_32FC3);
	oImage;
	cv::Mat oBlob = cv::dnn::blobFromImage(oImage - cv::Scalar(127.5, 127.5, 127.5), 1.0 / 127.5, cv::Size(nWidth, nHeight), cv::Scalar(0.0, 0.0, 0.0), true, false);
	cv::dnn::Net oNet;
	oNet = cv::dnn::readNetFromTensorflow(sPathToModel);
	oNet.setInput(oBlob);
	cv::Mat oDetectionMat = oNet.forward();
	return 0;
}"><pre class="notranslate">#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">"</span>StdAfx.h<span class="pl-pds">"</span></span>
#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>opencv2\core.hpp<span class="pl-pds">&gt;</span></span>
#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>opencv2\dnn.hpp<span class="pl-pds">&gt;</span></span>
#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>vld.h<span class="pl-pds">&gt;</span></span> <span class="pl-c"><span class="pl-c">//</span>&lt;-- for memory leak detection, see https://archive.codeplex.com/?p=vld</span>
<span class="pl-c"><span class="pl-c">//</span> entry point for MemoryLeakTestProjectOpenCV4</span>
<span class="pl-k">int</span> <span class="pl-en">main</span>(<span class="pl-k">int</span> <span class="pl-c"><span class="pl-c">/*</span>argc<span class="pl-c">*/</span></span>, <span class="pl-k">char</span>* <span class="pl-c"><span class="pl-c">/*</span>argv<span class="pl-c">*/</span></span>[ ])
{
	<span class="pl-k">const</span> <span class="pl-k">int</span> nWidth = <span class="pl-c1">300</span>;
	<span class="pl-k">const</span> <span class="pl-k">int</span> nHeight = <span class="pl-c1">300</span>;
	<span class="pl-k">const</span> std::string <span class="pl-smi">sPathToModel</span> = <span class="pl-s"><span class="pl-pds">"</span>C:/Projects/SSS-FPCoding/MemoryLeakTestProjectOpenCV4/Debug MD/x64/test.pb<span class="pl-pds">"</span></span>;
	cv::Mat oImage = <span class="pl-c1">cv::Mat::ones</span>(<span class="pl-c1">cv::Size</span>(nWidth, nHeight), CV_32FC3);
	oImage;
	cv::Mat oBlob = <span class="pl-c1">cv::dnn::blobFromImage</span>(oImage - <span class="pl-c1">cv::Scalar</span>(<span class="pl-c1">127.5</span>, <span class="pl-c1">127.5</span>, <span class="pl-c1">127.5</span>), <span class="pl-c1">1.0</span> / <span class="pl-c1">127.5</span>, <span class="pl-c1">cv::Size</span>(nWidth, nHeight), <span class="pl-c1">cv::Scalar</span>(<span class="pl-c1">0.0</span>, <span class="pl-c1">0.0</span>, <span class="pl-c1">0.0</span>), <span class="pl-c1">true</span>, <span class="pl-c1">false</span>);
	cv::dnn::Net oNet;
	oNet = <span class="pl-c1">cv::dnn::readNetFromTensorflow</span>(<span class="pl-smi">sPathToModel</span>);
	oNet.<span class="pl-c1">setInput</span>(oBlob);
	cv::Mat oDetectionMat = oNet.<span class="pl-c1">forward</span>();
	<span class="pl-k">return</span> <span class="pl-c1">0</span>;
}</pre></div>
<p dir="auto">When running this simple program, I get the following leak detection report:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="WARNING: Visual Leak Detector detected memory leaks!
---------- Block 1 at 0x00000000C7FCA570: 80 bytes ----------
  Leak Hash: 0xF3029A69, Count: 1, Total 80 bytes
  Call Stack (TID 10700):
    ucrtbased.dll!malloc()
    f:\dd\vctools\crt\vcstartup\src\heap\new_scalar.cpp (19): MemoryLeakTestCmdAndOpenCV4.exe!operator new() + 0xA bytes
    c:\users\sebert\downloads\opencv-master\modules\core\src\system.cpp (58): MemoryLeakTestCmdAndOpenCV4.exe!cv::getInitializationMutex() + 0xA bytes
    c:\users\sebert\downloads\opencv-master\modules\core\src\system.cpp (62): MemoryLeakTestCmdAndOpenCV4.exe!cv::`dynamic initializer for '__initialization_mutex_initializer''() + 0x1A bytes
    ucrtbased.dll!initterm() + 0x5D bytes
    f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (223): MemoryLeakTestCmdAndOpenCV4.exe!__scrt_common_main_seh()
    f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (296): MemoryLeakTestCmdAndOpenCV4.exe!__scrt_common_main()
    f:\dd\vctools\crt\vcstartup\src\startup\exe_main.cpp (17): MemoryLeakTestCmdAndOpenCV4.exe!mainCRTStartup()
    KERNEL32.DLL!BaseThreadInitThunk() + 0x14 bytes
    ntdll.dll!RtlUserThreadStart() + 0x21 bytes
  Data:
    02 01 00 00    CD CD CD CD    B8 25 97 90    F8 7F 00 00     ........ .%......
    00 00 00 00    00 00 00 00    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    FF FF FF FF    00 00 00 00     ........ ........


---------- Block 38732 at 0x00000000C7FCEA20: 256 bytes ----------
  Leak Hash: 0xC671A8C8, Count: 1, Total 256 bytes
  Call Stack (TID 10700):
    ucrtbased.dll!malloc()
    c:\program files (x86)\microsoft visual studio 14.0\vc\include\xmemory0 (977): MemoryLeakTestCmdAndOpenCV4.exe!std::_Wrap_alloc&lt;std::allocator&lt;void * __ptr64&gt; &gt;::allocate()
    c:\program files (x86)\microsoft visual studio 14.0\vc\include\vector (1602): MemoryLeakTestCmdAndOpenCV4.exe!std::vector&lt;void * __ptr64,std::allocator&lt;void * __ptr64&gt; &gt;::_Reallocate() + 0x1D bytes
    c:\program files (x86)\microsoft visual studio 14.0\vc\include\vector (1039): MemoryLeakTestCmdAndOpenCV4.exe!std::vector&lt;void * __ptr64,std::allocator&lt;void * __ptr64&gt; &gt;::reserve()
    c:\users\sebert\downloads\opencv-master\modules\core\src\system.cpp (1301): MemoryLeakTestCmdAndOpenCV4.exe!cv::ThreadData::ThreadData() + 0x12 bytes
    c:\users\sebert\downloads\opencv-master\modules\core\src\system.cpp (1441): MemoryLeakTestCmdAndOpenCV4.exe!cv::TlsStorage::setData() + 0x2A bytes
    c:\users\sebert\downloads\opencv-master\modules\core\src\system.cpp (1518): MemoryLeakTestCmdAndOpenCV4.exe!cv::TLSDataContainer::getData()
    c:\users\sebert\downloads\opencv-master\modules\core\include\opencv2\core\utility.hpp (684): MemoryLeakTestCmdAndOpenCV4.exe!cv::TLSData&lt;cv::CoreTLSData&gt;::get() + 0x28 bytes
    c:\users\sebert\downloads\opencv-master\modules\core\src\ocl.cpp (880): MemoryLeakTestCmdAndOpenCV4.exe!cv::ocl::useOpenCL() + 0xD bytes
    c:\users\sebert\downloads\opencv-master\modules\core\src\umatrix.cpp (232): MemoryLeakTestCmdAndOpenCV4.exe!cv::UMat::getStdAllocator() + 0x5 bytes
    c:\users\sebert\downloads\opencv-master\modules\core\src\umatrix.cpp (372): MemoryLeakTestCmdAndOpenCV4.exe!cv::Mat::getUMat() + 0x5 bytes
    c:\users\sebert\downloads\opencv-master\modules\dnn\src\layers\convolution_layer.cpp (1596): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::ConvolutionLayer::create() + 0x2F bytes
    c:\users\sebert\downloads\opencv-master\modules\dnn\include\opencv2\dnn\layer.details.hpp (53): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::details::_layerDynamicRegisterer&lt;cv::dnn::experimental_dnn_v4::ConvolutionLayer&gt;() + 0xF bytes
    c:\users\sebert\downloads\opencv-master\modules\dnn\src\dnn.cpp (2970): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::LayerFactory::createLayerInstance() + 0x2B bytes
    c:\users\sebert\downloads\opencv-master\modules\dnn\src\dnn.cpp (389): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::LayerData::getLayerInstance() + 0x28 bytes
    c:\users\sebert\downloads\opencv-master\modules\dnn\src\dnn.cpp (1902): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::Net::Impl::getLayerShapesRecursively() + 0x2C bytes
    c:\users\sebert\downloads\opencv-master\modules\dnn\src\dnn.cpp (1915): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::Net::Impl::getLayersShapes() + 0x21 bytes
    c:\users\sebert\downloads\opencv-master\modules\dnn\src\dnn.cpp (1749): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::Net::Impl::allocateLayers()
    c:\users\sebert\downloads\opencv-master\modules\dnn\src\dnn.cpp (875): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::Net::Impl::setUpNet()
    c:\users\sebert\downloads\opencv-master\modules\dnn\src\dnn.cpp (2080): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::Net::forward() + 0x45 bytes
    c:\projects\sss-fpcoding\memoryleaktestprojectopencv4\memoryleaktestprojectopencv4.cpp (17): MemoryLeakTestCmdAndOpenCV4.exe!main() + 0x42 bytes
    f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (65): MemoryLeakTestCmdAndOpenCV4.exe!invoke_main()
    f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (253): MemoryLeakTestCmdAndOpenCV4.exe!__scrt_common_main_seh() + 0x5 bytes
    f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (296): MemoryLeakTestCmdAndOpenCV4.exe!__scrt_common_main()
    f:\dd\vctools\crt\vcstartup\src\startup\exe_main.cpp (17): MemoryLeakTestCmdAndOpenCV4.exe!mainCRTStartup()
    KERNEL32.DLL!BaseThreadInitThunk() + 0x14 bytes
    ntdll.dll!RtlUserThreadStart() + 0x21 bytes
  Data:
    F0 8E 95 C8    D5 01 00 00    B0 38 FE C7    D5 01 00 00     ........ .8......
    D0 61 A5 D0    D5 01 00 00    CD CD CD CD    CD CD CD CD     .a...... ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........


---------- Block 38746 at 0x00000000C7FCF060: 256 bytes ----------
  Leak Hash: 0x03BE8C52, Count: 1, Total 256 bytes
  Call Stack (TID 10700):
    ucrtbased.dll!malloc()
    f:\dd\vctools\crt\vcstartup\src\heap\new_scalar.cpp (19): MemoryLeakTestCmdAndOpenCV4.exe!operator new() + 0xA bytes
    c:\users\sebert\downloads\opencv-master\modules\core\src\ocl.cpp (2371): MemoryLeakTestCmdAndOpenCV4.exe!cv::ocl::Context::getDefault() + 0xA bytes
    c:\users\sebert\downloads\opencv-master\modules\core\src\ocl.cpp (1617): MemoryLeakTestCmdAndOpenCV4.exe!cv::ocl::Device::getDefault() + 0x7 bytes
    c:\users\sebert\downloads\opencv-master\modules\core\src\ocl.cpp (885): MemoryLeakTestCmdAndOpenCV4.exe!cv::ocl::useOpenCL() + 0x11 bytes
    c:\users\sebert\downloads\opencv-master\modules\core\src\umatrix.cpp (232): MemoryLeakTestCmdAndOpenCV4.exe!cv::UMat::getStdAllocator() + 0x5 bytes
    c:\users\sebert\downloads\opencv-master\modules\core\src\umatrix.cpp (372): MemoryLeakTestCmdAndOpenCV4.exe!cv::Mat::getUMat() + 0x5 bytes
    c:\users\sebert\downloads\opencv-master\modules\dnn\src\layers\convolution_layer.cpp (1596): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::ConvolutionLayer::create() + 0x2F bytes
    c:\users\sebert\downloads\opencv-master\modules\dnn\include\opencv2\dnn\layer.details.hpp (53): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::details::_layerDynamicRegisterer&lt;cv::dnn::experimental_dnn_v4::ConvolutionLayer&gt;() + 0xF bytes
    c:\users\sebert\downloads\opencv-master\modules\dnn\src\dnn.cpp (2970): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::LayerFactory::createLayerInstance() + 0x2B bytes
    c:\users\sebert\downloads\opencv-master\modules\dnn\src\dnn.cpp (389): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::LayerData::getLayerInstance() + 0x28 bytes
    c:\users\sebert\downloads\opencv-master\modules\dnn\src\dnn.cpp (1902): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::Net::Impl::getLayerShapesRecursively() + 0x2C bytes
    c:\users\sebert\downloads\opencv-master\modules\dnn\src\dnn.cpp (1915): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::Net::Impl::getLayersShapes() + 0x21 bytes
    c:\users\sebert\downloads\opencv-master\modules\dnn\src\dnn.cpp (1749): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::Net::Impl::allocateLayers()
    c:\users\sebert\downloads\opencv-master\modules\dnn\src\dnn.cpp (875): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::Net::Impl::setUpNet()
    c:\users\sebert\downloads\opencv-master\modules\dnn\src\dnn.cpp (2080): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::Net::forward() + 0x45 bytes
    c:\projects\sss-fpcoding\memoryleaktestprojectopencv4\memoryleaktestprojectopencv4.cpp (17): MemoryLeakTestCmdAndOpenCV4.exe!main() + 0x42 bytes
    f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (65): MemoryLeakTestCmdAndOpenCV4.exe!invoke_main()
    f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (253): MemoryLeakTestCmdAndOpenCV4.exe!__scrt_common_main_seh() + 0x5 bytes
    f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (296): MemoryLeakTestCmdAndOpenCV4.exe!__scrt_common_main()
    f:\dd\vctools\crt\vcstartup\src\startup\exe_main.cpp (17): MemoryLeakTestCmdAndOpenCV4.exe!mainCRTStartup()
    KERNEL32.DLL!BaseThreadInitThunk() + 0x14 bytes
    ntdll.dll!RtlUserThreadStart() + 0x21 bytes
  Data:
    01 00 00 00    CD CD CD CD    20 29 FE C7    D5 01 00 00     ........ .)......
    F0 AC 93 C8    D5 01 00 00    B0 E0 03 C8    D5 01 00 00     ........ ........
    B8 E0 03 C8    D5 01 00 00    B8 E0 03 C8    D5 01 00 00     ........ ........
    80 A9 93 C8    D5 01 00 00    00 CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    00 00 00 00    00 00 00 00     ........ ........
    0F 00 00 00    00 00 00 00    70 AA 93 C8    D5 01 00 00     ........ p.......
    00 CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    00 00 00 00    00 00 00 00    0F 00 00 00    00 00 00 00     ........ ........
    02 01 00 00    CD CD CD CD    B8 25 97 90    F8 7F 00 00     ........ .%......
    00 00 00 00    00 00 00 00    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    FF FF FF FF    00 00 00 00     ........ ........
    C0 A5 93 C8    D5 01 00 00    C0 29 00 C8    D5 01 00 00     ........ .)......
    00 00 00 00    00 00 00 00    C0 AA 93 C8    D5 01 00 00     ........ ........
    10 D8 0B C8    D5 01 00 00    00 00 00 00    00 00 00 00     ........ ........

...many more blocks...
...please see attached .txt for full leak report...
[memoryleakreport_30.7.2018.opencv4.txt](https://github.com/opencv/opencv/files/2240396/memoryleakreport_30.7.2018.opencv4.txt)



Visual Leak Detector detected 128 memory leaks (14924 bytes).
Largest number used: 20520922 bytes.
Total allocations: 46858788 bytes.
Visual Leak Detector is now exiting.
The program '[9328] MemoryLeakTestCmdAndOpenCV4.exe' has exited with code 0 (0x0)."><pre lang="..." class="notranslate"><code class="notranslate">WARNING: Visual Leak Detector detected memory leaks!
---------- Block 1 at 0x00000000C7FCA570: 80 bytes ----------
  Leak Hash: 0xF3029A69, Count: 1, Total 80 bytes
  Call Stack (TID 10700):
    ucrtbased.dll!malloc()
    f:\dd\vctools\crt\vcstartup\src\heap\new_scalar.cpp (19): MemoryLeakTestCmdAndOpenCV4.exe!operator new() + 0xA bytes
    c:\users\sebert\downloads\opencv-master\modules\core\src\system.cpp (58): MemoryLeakTestCmdAndOpenCV4.exe!cv::getInitializationMutex() + 0xA bytes
    c:\users\sebert\downloads\opencv-master\modules\core\src\system.cpp (62): MemoryLeakTestCmdAndOpenCV4.exe!cv::`dynamic initializer for '__initialization_mutex_initializer''() + 0x1A bytes
    ucrtbased.dll!initterm() + 0x5D bytes
    f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (223): MemoryLeakTestCmdAndOpenCV4.exe!__scrt_common_main_seh()
    f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (296): MemoryLeakTestCmdAndOpenCV4.exe!__scrt_common_main()
    f:\dd\vctools\crt\vcstartup\src\startup\exe_main.cpp (17): MemoryLeakTestCmdAndOpenCV4.exe!mainCRTStartup()
    KERNEL32.DLL!BaseThreadInitThunk() + 0x14 bytes
    ntdll.dll!RtlUserThreadStart() + 0x21 bytes
  Data:
    02 01 00 00    CD CD CD CD    B8 25 97 90    F8 7F 00 00     ........ .%......
    00 00 00 00    00 00 00 00    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    FF FF FF FF    00 00 00 00     ........ ........


---------- Block 38732 at 0x00000000C7FCEA20: 256 bytes ----------
  Leak Hash: 0xC671A8C8, Count: 1, Total 256 bytes
  Call Stack (TID 10700):
    ucrtbased.dll!malloc()
    c:\program files (x86)\microsoft visual studio 14.0\vc\include\xmemory0 (977): MemoryLeakTestCmdAndOpenCV4.exe!std::_Wrap_alloc&lt;std::allocator&lt;void * __ptr64&gt; &gt;::allocate()
    c:\program files (x86)\microsoft visual studio 14.0\vc\include\vector (1602): MemoryLeakTestCmdAndOpenCV4.exe!std::vector&lt;void * __ptr64,std::allocator&lt;void * __ptr64&gt; &gt;::_Reallocate() + 0x1D bytes
    c:\program files (x86)\microsoft visual studio 14.0\vc\include\vector (1039): MemoryLeakTestCmdAndOpenCV4.exe!std::vector&lt;void * __ptr64,std::allocator&lt;void * __ptr64&gt; &gt;::reserve()
    c:\users\sebert\downloads\opencv-master\modules\core\src\system.cpp (1301): MemoryLeakTestCmdAndOpenCV4.exe!cv::ThreadData::ThreadData() + 0x12 bytes
    c:\users\sebert\downloads\opencv-master\modules\core\src\system.cpp (1441): MemoryLeakTestCmdAndOpenCV4.exe!cv::TlsStorage::setData() + 0x2A bytes
    c:\users\sebert\downloads\opencv-master\modules\core\src\system.cpp (1518): MemoryLeakTestCmdAndOpenCV4.exe!cv::TLSDataContainer::getData()
    c:\users\sebert\downloads\opencv-master\modules\core\include\opencv2\core\utility.hpp (684): MemoryLeakTestCmdAndOpenCV4.exe!cv::TLSData&lt;cv::CoreTLSData&gt;::get() + 0x28 bytes
    c:\users\sebert\downloads\opencv-master\modules\core\src\ocl.cpp (880): MemoryLeakTestCmdAndOpenCV4.exe!cv::ocl::useOpenCL() + 0xD bytes
    c:\users\sebert\downloads\opencv-master\modules\core\src\umatrix.cpp (232): MemoryLeakTestCmdAndOpenCV4.exe!cv::UMat::getStdAllocator() + 0x5 bytes
    c:\users\sebert\downloads\opencv-master\modules\core\src\umatrix.cpp (372): MemoryLeakTestCmdAndOpenCV4.exe!cv::Mat::getUMat() + 0x5 bytes
    c:\users\sebert\downloads\opencv-master\modules\dnn\src\layers\convolution_layer.cpp (1596): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::ConvolutionLayer::create() + 0x2F bytes
    c:\users\sebert\downloads\opencv-master\modules\dnn\include\opencv2\dnn\layer.details.hpp (53): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::details::_layerDynamicRegisterer&lt;cv::dnn::experimental_dnn_v4::ConvolutionLayer&gt;() + 0xF bytes
    c:\users\sebert\downloads\opencv-master\modules\dnn\src\dnn.cpp (2970): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::LayerFactory::createLayerInstance() + 0x2B bytes
    c:\users\sebert\downloads\opencv-master\modules\dnn\src\dnn.cpp (389): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::LayerData::getLayerInstance() + 0x28 bytes
    c:\users\sebert\downloads\opencv-master\modules\dnn\src\dnn.cpp (1902): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::Net::Impl::getLayerShapesRecursively() + 0x2C bytes
    c:\users\sebert\downloads\opencv-master\modules\dnn\src\dnn.cpp (1915): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::Net::Impl::getLayersShapes() + 0x21 bytes
    c:\users\sebert\downloads\opencv-master\modules\dnn\src\dnn.cpp (1749): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::Net::Impl::allocateLayers()
    c:\users\sebert\downloads\opencv-master\modules\dnn\src\dnn.cpp (875): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::Net::Impl::setUpNet()
    c:\users\sebert\downloads\opencv-master\modules\dnn\src\dnn.cpp (2080): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::Net::forward() + 0x45 bytes
    c:\projects\sss-fpcoding\memoryleaktestprojectopencv4\memoryleaktestprojectopencv4.cpp (17): MemoryLeakTestCmdAndOpenCV4.exe!main() + 0x42 bytes
    f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (65): MemoryLeakTestCmdAndOpenCV4.exe!invoke_main()
    f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (253): MemoryLeakTestCmdAndOpenCV4.exe!__scrt_common_main_seh() + 0x5 bytes
    f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (296): MemoryLeakTestCmdAndOpenCV4.exe!__scrt_common_main()
    f:\dd\vctools\crt\vcstartup\src\startup\exe_main.cpp (17): MemoryLeakTestCmdAndOpenCV4.exe!mainCRTStartup()
    KERNEL32.DLL!BaseThreadInitThunk() + 0x14 bytes
    ntdll.dll!RtlUserThreadStart() + 0x21 bytes
  Data:
    F0 8E 95 C8    D5 01 00 00    B0 38 FE C7    D5 01 00 00     ........ .8......
    D0 61 A5 D0    D5 01 00 00    CD CD CD CD    CD CD CD CD     .a...... ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........


---------- Block 38746 at 0x00000000C7FCF060: 256 bytes ----------
  Leak Hash: 0x03BE8C52, Count: 1, Total 256 bytes
  Call Stack (TID 10700):
    ucrtbased.dll!malloc()
    f:\dd\vctools\crt\vcstartup\src\heap\new_scalar.cpp (19): MemoryLeakTestCmdAndOpenCV4.exe!operator new() + 0xA bytes
    c:\users\sebert\downloads\opencv-master\modules\core\src\ocl.cpp (2371): MemoryLeakTestCmdAndOpenCV4.exe!cv::ocl::Context::getDefault() + 0xA bytes
    c:\users\sebert\downloads\opencv-master\modules\core\src\ocl.cpp (1617): MemoryLeakTestCmdAndOpenCV4.exe!cv::ocl::Device::getDefault() + 0x7 bytes
    c:\users\sebert\downloads\opencv-master\modules\core\src\ocl.cpp (885): MemoryLeakTestCmdAndOpenCV4.exe!cv::ocl::useOpenCL() + 0x11 bytes
    c:\users\sebert\downloads\opencv-master\modules\core\src\umatrix.cpp (232): MemoryLeakTestCmdAndOpenCV4.exe!cv::UMat::getStdAllocator() + 0x5 bytes
    c:\users\sebert\downloads\opencv-master\modules\core\src\umatrix.cpp (372): MemoryLeakTestCmdAndOpenCV4.exe!cv::Mat::getUMat() + 0x5 bytes
    c:\users\sebert\downloads\opencv-master\modules\dnn\src\layers\convolution_layer.cpp (1596): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::ConvolutionLayer::create() + 0x2F bytes
    c:\users\sebert\downloads\opencv-master\modules\dnn\include\opencv2\dnn\layer.details.hpp (53): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::details::_layerDynamicRegisterer&lt;cv::dnn::experimental_dnn_v4::ConvolutionLayer&gt;() + 0xF bytes
    c:\users\sebert\downloads\opencv-master\modules\dnn\src\dnn.cpp (2970): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::LayerFactory::createLayerInstance() + 0x2B bytes
    c:\users\sebert\downloads\opencv-master\modules\dnn\src\dnn.cpp (389): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::LayerData::getLayerInstance() + 0x28 bytes
    c:\users\sebert\downloads\opencv-master\modules\dnn\src\dnn.cpp (1902): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::Net::Impl::getLayerShapesRecursively() + 0x2C bytes
    c:\users\sebert\downloads\opencv-master\modules\dnn\src\dnn.cpp (1915): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::Net::Impl::getLayersShapes() + 0x21 bytes
    c:\users\sebert\downloads\opencv-master\modules\dnn\src\dnn.cpp (1749): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::Net::Impl::allocateLayers()
    c:\users\sebert\downloads\opencv-master\modules\dnn\src\dnn.cpp (875): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::Net::Impl::setUpNet()
    c:\users\sebert\downloads\opencv-master\modules\dnn\src\dnn.cpp (2080): MemoryLeakTestCmdAndOpenCV4.exe!cv::dnn::experimental_dnn_v4::Net::forward() + 0x45 bytes
    c:\projects\sss-fpcoding\memoryleaktestprojectopencv4\memoryleaktestprojectopencv4.cpp (17): MemoryLeakTestCmdAndOpenCV4.exe!main() + 0x42 bytes
    f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (65): MemoryLeakTestCmdAndOpenCV4.exe!invoke_main()
    f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (253): MemoryLeakTestCmdAndOpenCV4.exe!__scrt_common_main_seh() + 0x5 bytes
    f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (296): MemoryLeakTestCmdAndOpenCV4.exe!__scrt_common_main()
    f:\dd\vctools\crt\vcstartup\src\startup\exe_main.cpp (17): MemoryLeakTestCmdAndOpenCV4.exe!mainCRTStartup()
    KERNEL32.DLL!BaseThreadInitThunk() + 0x14 bytes
    ntdll.dll!RtlUserThreadStart() + 0x21 bytes
  Data:
    01 00 00 00    CD CD CD CD    20 29 FE C7    D5 01 00 00     ........ .)......
    F0 AC 93 C8    D5 01 00 00    B0 E0 03 C8    D5 01 00 00     ........ ........
    B8 E0 03 C8    D5 01 00 00    B8 E0 03 C8    D5 01 00 00     ........ ........
    80 A9 93 C8    D5 01 00 00    00 CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    00 00 00 00    00 00 00 00     ........ ........
    0F 00 00 00    00 00 00 00    70 AA 93 C8    D5 01 00 00     ........ p.......
    00 CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    00 00 00 00    00 00 00 00    0F 00 00 00    00 00 00 00     ........ ........
    02 01 00 00    CD CD CD CD    B8 25 97 90    F8 7F 00 00     ........ .%......
    00 00 00 00    00 00 00 00    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    FF FF FF FF    00 00 00 00     ........ ........
    C0 A5 93 C8    D5 01 00 00    C0 29 00 C8    D5 01 00 00     ........ .)......
    00 00 00 00    00 00 00 00    C0 AA 93 C8    D5 01 00 00     ........ ........
    10 D8 0B C8    D5 01 00 00    00 00 00 00    00 00 00 00     ........ ........

...many more blocks...
...please see attached .txt for full leak report...
[memoryleakreport_30.7.2018.opencv4.txt](https://github.com/opencv/opencv/files/2240396/memoryleakreport_30.7.2018.opencv4.txt)



Visual Leak Detector detected 128 memory leaks (14924 bytes).
Largest number used: 20520922 bytes.
Total allocations: 46858788 bytes.
Visual Leak Detector is now exiting.
The program '[9328] MemoryLeakTestCmdAndOpenCV4.exe' has exited with code 0 (0x0).
</code></pre></div>