<h5 dir="auto">System information</h5>
<ul dir="auto">
<li>OpenCV =&gt; 4.0.1  (Exactly, I am using OpenCV lib included in OpenVINO R5 2018 release.)</li>
<li>Operating System / Platform =&gt; Windows 64 Bit</li>
<li>Compiler =&gt; Visual Studio 2015</li>
</ul>
<h5 dir="auto">Detailed description</h5>
<p dir="auto">Memory increases quickly as i run my code.<br>
My code is really simple:  Create 2000 threads, and in each thread try to create a UMAT.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="#include &quot;stdafx.h&quot;
#include &lt;iostream&gt;
#include &lt;opencv2/core.hpp&gt;
#include &lt;opencv2/imgproc.hpp&gt;
#include &lt;opencv2/highgui.hpp&gt;
#include &lt;mutex&gt;
#include &lt;condition_variable&gt;
#include &lt;atomic&gt;

#define DECODECORE_ROI_IMAGE_WIDTH 480
#define DECODECORE_ROI_IMAGE_HEIGHT 640
unsigned char resized[DECODECORE_ROI_IMAGE_WIDTH * DECODECORE_ROI_IMAGE_HEIGHT];


void TestThread()
{
	std::cout &lt;&lt; &quot;TestThread started\n&quot;;

	cv::Mat srcMat(DECODECORE_ROI_IMAGE_WIDTH, DECODECORE_ROI_IMAGE_HEIGHT, CV_8UC1, resized);
	cv::UMat uMsrcImg = srcMat.getUMat(cv::ACCESS_READ);
	uMsrcImg.release();
	srcMat.release();
}
int main()
{
	for (int i = 0; i &lt; 2000; i++)
	{
		std::thread finderThread = std::thread(TestThread);
		finderThread.detach();
		std::cout &lt;&lt; &quot;i is &quot; &lt;&lt; i &lt;&lt; &quot;\n&quot;;
	}
	return 0;
}"><pre class="notranslate"><code class="notranslate">#include "stdafx.h"
#include &lt;iostream&gt;
#include &lt;opencv2/core.hpp&gt;
#include &lt;opencv2/imgproc.hpp&gt;
#include &lt;opencv2/highgui.hpp&gt;
#include &lt;mutex&gt;
#include &lt;condition_variable&gt;
#include &lt;atomic&gt;

#define DECODECORE_ROI_IMAGE_WIDTH 480
#define DECODECORE_ROI_IMAGE_HEIGHT 640
unsigned char resized[DECODECORE_ROI_IMAGE_WIDTH * DECODECORE_ROI_IMAGE_HEIGHT];


void TestThread()
{
	std::cout &lt;&lt; "TestThread started\n";

	cv::Mat srcMat(DECODECORE_ROI_IMAGE_WIDTH, DECODECORE_ROI_IMAGE_HEIGHT, CV_8UC1, resized);
	cv::UMat uMsrcImg = srcMat.getUMat(cv::ACCESS_READ);
	uMsrcImg.release();
	srcMat.release();
}
int main()
{
	for (int i = 0; i &lt; 2000; i++)
	{
		std::thread finderThread = std::thread(TestThread);
		finderThread.detach();
		std::cout &lt;&lt; "i is " &lt;&lt; i &lt;&lt; "\n";
	}
	return 0;
}
</code></pre></div>
<ul dir="auto">
<li>OpenCV =&gt; 3.3.0</li>
<li>Operating System / Platform =&gt; Arch Linux (4.12.13-1-ARCH SMP PREEMPT x86_64 GNU/Linux)</li>
<li>Compiler =&gt; gcc 7.2.0 and clang 5.0.0</li>
</ul>
<h5 dir="auto">Detailed description</h5>
<p dir="auto">It seems that a significant portion of memory is leaked in every thread.<br>
The following code snippet consumes cca 100MB/s.</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 &lt;opencv2/opencv.hpp&gt;
#include &lt;future&gt;
int main()
{
    while(true) {
        std::async(std::launch::async, []() { cv::Mat::zeros(1, 1, CV_32FC3); }).wait();
    }
}"><pre class="notranslate">#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>opencv2/opencv.hpp<span class="pl-pds">&gt;</span></span>
#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>future<span class="pl-pds">&gt;</span></span>
<span class="pl-k">int</span> <span class="pl-en">main</span>()
{
    <span class="pl-k">while</span>(<span class="pl-c1">true</span>) {
        <span class="pl-c1">std::async</span>(std::launch::async, []() { <span class="pl-c1">cv::Mat::zeros</span>(<span class="pl-c1">1</span>, <span class="pl-c1">1</span>, CV_32FC3); }).<span class="pl-c1">wait</span>();
    }
}</pre></div>