# Memory leak in OpenCV 4.20

**URL:** <https://forum.opencv.org/t/memory-leak-in-opencv-4-20/16123>\
**Category:** C++\
**Tags:** leaks\
**Created:** [January 11, 2024, 7:18am UTC](https://forum.opencv.org/t/memory-leak-in-opencv-4-20/16123 "2024-01-11T07:18:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hsuan\_J](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/hsuan_j/32/9469_2.png) [@Hsuan\_J](https://forum.opencv.org/u/Hsuan_J)\
**Post date:** [January 11, 2024, 7:18am UTC](https://forum.opencv.org/t/memory-leak-in-opencv-4-20/16123/1 "2024-01-11T07:18:35Z")

</div>

Windows 10, Visual Studio 2015, OpenCV 4.20 compiled successfully and got memory leak .

Tried:

- Use different versions of OpenCV
- Delay load dll

Code Example:  
#include \<…opencv2\core.hpp\>  
cv::Mat mat;

Memory leak Message:  
Detected memory leaks!  
Dumping objects →   
{7183} normal block at 0x00000148263D8480, 16 bytes long.  
Data: 78 06 05 7F FE 7F 00 00 00 00 00 00 00 00 00 00  
{7182} normal block at 0x00000148263D8110, 16 bytes long.  
Data: \< \> F0 06 05 7F FE 7F 00 00 00 00 00 00 00 00 00 00  
{7181} normal block at 0x00000148263D80C0, 16 bytes long.  
Data: \< \> A0 06 05 7F FE 7F 00 00 00 00 00 00 00 00 00 00

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [January 11, 2024, 7:58am UTC](https://forum.opencv.org/t/memory-leak-in-opencv-4-20/16123/2 "2024-01-11T07:58:17Z")

</div>

> [@Hsuan\_J](#):
>
> 4.20

that is a very old release.

if you found an issue in 4.2.0, it could have been fixed since then.

please update to latest release and try again.

“leaks” of small or bounded size are not practically considered leaks. you’ve got a case if you can cause arbitrary amounts of leakage (and gigabytes at least).

---

<div class="post-metadata">

**Author:** ![Hsuan\_J](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/hsuan_j/32/9469_2.png) [@Hsuan\_J](https://forum.opencv.org/u/Hsuan_J)\
**Post date:** [January 12, 2024, 3:02am UTC](https://forum.opencv.org/t/memory-leak-in-opencv-4-20/16123/4 "2024-01-12T03:02:56Z")

</div>

> [@crackwitz](#):
>
> please update to latest release and try again.

Thanks for your reply! 🙂  
I’ve also tried version 4.8.0 but still have memory leak issue.

---

<div class="post-metadata">

**Author:** ![matti.vuori](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@matti.vuori](https://forum.opencv.org/u/matti.vuori)\
**Post date:** [January 12, 2024, 6:45am UTC](https://forum.opencv.org/t/memory-leak-in-opencv-4-20/16123/5 "2024-01-12T06:45:21Z")

</div>

No, you don’t have an issue. Tiny amount of unreleased memory at the exit of any program is normal - the OS will release it… You’d have an issue, it there was a continuous leak during the execution.

---

<div class="post-metadata">

**Author:** ![Laurent](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/laurent/32/13368_2.png) [@Laurent](https://forum.opencv.org/u/Laurent)\
**Post date:** [January 3, 2026, 3:50am UTC](https://forum.opencv.org/t/memory-leak-in-opencv-4-20/16123/6 "2026-01-03T03:50:18Z")

</div>

> [@Memory leaks compiling C++ MFC App in debug mode](https://forum.opencv.org/t/memory-leaks-compiling-c-mfc-app-in-debug-mode/5647/4):
>
> Strategic Leak Avoidance: Handling OpenCV Memory Leaks in MFC I am posting this in 2026 for anyone struggling with this issue. After trying various methods, I’ve found that the most effective approach is Strategic Leak Avoidance. The Root Cause In MFC, these “leaks” often occur because OpenCV utilizes global memory pools or thread managers (like TBB/OpenMP) for performance optimization. These components are typically cleaned up only when the program is fully unloaded from memory (DLL Unload). B…
