U++ framework
Do not panic. Ask here before giving up.

Home » U++ Library support » U++ Core » Heap leak reported when using OpenCV in U++ Application.
Heap leak reported when using OpenCV in U++ Application. [message #61953] Tue, 24 March 2026 08:22 Go to next message
nikitha_k is currently offline  nikitha_k
Messages: 8
Registered: July 2023
Location: Banglore
Promising Member
Hi,

I am working on a U++ GUI application with OpenCV integration.

I noticed that heap leaks are reported when the application exits. The program runs correctly and displays output, but when closing the GUI window, many heap leaks are shown.

I tested with minimal code and observed:

* Without using OpenCV → no heap leak
* With a simple OpenCV `cv::Mat` → heap leak appears
* Even with larger code, the reported leak size remains the same

Is this expected behavior when using OpenCV with U++, or could this indicate an issue?
Also, how can this problem be resolved?


log file:

Heap leaks detected:

--memory-breakpoint__ 250483 : Memory at 0x0x7fcc3ed5e620, size 0x7C = 124
   +0 0x00007FCC3ED5E620 09 00 00 00 00 00 00 00 00 00 00 00 46 72 65 65     ............Free
  +16 0x00007FCC3ED5E630 C0 E6 5D 48 CC 7F 00 00 50 FC 00 14 CC 7F 00 00     ..]H...P......
  +32 0x00007FCC3ED5E640 00 00 00 00 00 00 00 00 00 00 00 00 46 72 65 65     ............Free
  +48 0x00007FCC3ED5E650 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00     ................

--memory-breakpoint__ 250480 : Memory at 0x0x7fcc3ed5e260, size 0x7C = 124
   +0 0x00007FCC3ED5E260 98 CE 78 48 CC 7F 00 00 00 00 00 00 00 00 00 00     ..xH...........
  +16 0x00007FCC3ED5E270 2B 00 65 65 03 00 00 00 80 F1 D5 3E CC 7F 00 00     +.ee.......>...
  +32 0x00007FCC3ED5E280 00 00 00 00 00 00 00 00 40 1B D6 3E CC 7F 00 00     ........@..>...
  +48 0x00007FCC3ED5E290 A8 E2 D5 3E CC 7F 00 00 00 00 00 00 00 00 00 00     ...>...........

--memory-breakpoint__ 250479 : Memory at 0x0x7fcc3ed5e1c0, size 0x7C = 124
   +0 0x00007FCC3ED5E1C0 06 00 00 00 00 00 00 00 00 00 00 00 46 72 65 65     ............Free
  +16 0x00007FCC3ED5E1D0 C0 E6 5D 48 CC 7F 00 00 70 CA 00 14 CC 7F 00 00     ..]H...p......
  +32 0x00007FCC3ED5E1E0 00 00 00 00 00 00 00 00 00 00 00 00 46 72 65 65     ............Free
  +48 0x00007FCC3ED5E1F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00     ................

--memory-breakpoint__ 250476 : Memory at 0x0x7fcc3ed5e120, size 0x7C = 124
   +0 0x00007FCC3ED5E120 98 CE 78 48 CC 7F 00 00 00 00 00 00 00 00 00 00     ..xH...........
  +16 0x00007FCC3ED5E130 2B 00 65 65 03 00 00 00 60 F0 D5 3E CC 7F 00 00     +.ee....`..>...
  +32 0x00007FCC3ED5E140 00 00 00 00 00 00 00 00 C0 10 D6 3E CC 7F 00 00     ...........>...
  +48 0x00007FCC3ED5E150 68 E1 D5 3E CC 7F 00 00 00 00 00 00 00 00 00 00     h..>...........

--memory-breakpoint__ 249253 : Memory at 0x0x7fcc3ed3e4e0, size 0x21C = 540
   +0 0x00007FCC3ED3E4E0 01 00 00 00 46 72 65 65 80 70 C2 3E CC 7F 00 00     ....Free.p.>...
  +16 0x00007FCC3ED3E4F0 60 6C C2 3E CC 7F 00 00 00 6D C2 3E CC 7F 00 00     `l.>....m.>...
  +32 0x00007FCC3ED3E500 A0 78 C2 3E CC 7F 0

Heap leaks detected:

--memory-breakpoint__ 160193 : Memory at 0x0x7f043f167620, size 0x7C = 124
   +0 0x00007F043F167620 09 00 00 00 00 00 00 00 00 00 00 00 46 72 65 65     ............Free
  +16 0x00007F043F167630 C0 E6 9D 48 04 7F 00 00 D0 06 01 14 04 7F 00 00     ...H..........
  +32 0x00007F043F167640 00 00 00 00 00 00 00 00 00 00 00 00 46 72 65 65     ............Free
  +48 0x00007F043F167650 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00     ................

--memory-breakpoint__ 160190 : Memory at 0x0x7f043f167260, size 0x7C = 124
   +0 0x00007F043F167260 98 CE B8 48 04 7F 00 00 00 00 00 00 00 00 00 00     ...H...........
  +16 0x00007F043F167270 2B 00 65 65 03 00 00 00 80 81 16 3F 04 7F 00 00     +.ee.......?...
  +32 0x00007F043F167280 00 00 00 00 00 00 00 00 40 AB 16 3F 04 7F 00 00     ........@..?...
  +48 0x00007F043F167290 A8 72 16 3F 04 7F 00 00 00 00 00 00 00 00 00 00     .r.?...........

--memory-breakpoint__ 160189 : Memory at 0x0x7f043f1671c0, size 0x7C = 124
   +0 0x00007F043F1671C0 06 00 00 00 00 00 00 00 00 00 00 00 46 72 65 65     ............Free
  +16 0x00007F043F1671D0 C0 E6 9D 48 04 7F 00 00 70 26 00 10 04 7F 00 00     ...H...p&.....
  +32 0x00007F043F1671E0 00 00 00 00 00 00 00 00 00 00 00 00 46 72 65 65     ............Free
  +48 0x00007F043F1671F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00     ................

--memory-breakpoint__ 160186 : Memory at 0x0x7f043f167120, size 0x7C = 124
   +0 0x00007F043F167120 98 CE B8 48 04 7F 00 00 00 00 00 00 00 00 00 00     ...H...........
  +16 0x00007F043F167130 2B 00 65 65 03 00 00 00 60 80 16 3F 04 7F 00 00     +.ee....`..?...
  +32 0x00007F043F167140 00 00 00 00 00 00 00 00 C0 A0 16 3F 04 7F 00 00     ...........?...
  +48 0x00007F043F167150 68 71 16 3F 04 7F 00 00 00 00 00 00 00 00 00 00     hq.?...........

--memory-breakpoint__ 159778 : Memory at 0x0x7f043f0c39e0, size 0x7C = 124
   +0 0x00007F043F0C39E0 20 41 B8 48 04 7F 00 00 40 E5 1A 3F 04 7F 00 00      A.H...@..?...
  +16 0x00007F043F0C39F0 00 00 00 00 00 00 00 00 E0 EF 9D 48 04 7F 00 00     ...........H...
  +32 0x00007F043F0C3A00 30 72 65 65 00 00 00 00 00 00 00 00 00 00 00 00     0ree............
  +48 0x00007F043F0C3A10 00 00 00 00 00 00 00 00 40 64 13 3F 04 7F 00 00     ........@d.?...

--memory-breakpoint__ 159777 : Memory at 0x0x7f043f1ae540, size 0x3C = 60
   +0 0x00007F043F1AE540 C8 0C FF 29 04 7F 00 00 E0 39 0C 3F 04 7F 00 00     ...)....9.?...
  +16 0x00007F043F1AE550 01 00 00 00 46 72 65 65 20 6C 0E 3F 04 7F 00 00     ....Free l.?...
  +32 0x00007F043F1AE560 E0 EF 9D 48 04 7F 00 00 C0 E6 9D 48 04 7F 00 00     ...H......H...
  +48 0x00007F043F1AE570 46 72 65 65 46 72 65 65 46 72 65 65                 FreeFreeFree    

--memory-breakpoint__ 159760 : Memory at 0x0x7f043f183b20, size 0x1C = 28
   +0 0x00007F043F183B20 01 00 00 00 FF FF FF FF 46 72 65 65 46 72 65 65     ........FreeFree
  +16 0x00007F043F183B30 46 72 65 65 46 72 65 65 46 72 65 65                 FreeFreeFree    

--memory-breakpoint__ 159073 : Memory at 0x0x7f043f1b0ba0, size 0x5C = 92
   +0 0x00007F043F1B0BA0 50 CE B8 48 04 7F 00 00 A0 3B 18 3F 04 7F 00 00     P..H....;.?...
  +16 0x00007F043F1B0BB0 00 00 00 00 00 00 00 00 E0 EF 9D 48 04 7F 00 00     ...........H...
  +32 0x00007F043F1B0BC0 30 72 65 65 00 00 00 00 00 00 00 00 00 00 00 00     0ree............
  +48 0x00007F043F1B0BD0 00 00 00 00 00 00 00 00 40 64 13 3F 04 7F 00 00     ........@d.?...

--memory-breakpoint__ 159072 : Memory at 0x0x7f043f183ba0, size 0x1C = 28
   +0 0x00007F043F183BA0 88 BD 2F 49 04 7F 00 00 A0 0B 1B 3F 04 7F 00 00     ../I......?...
  +16 0x00007F043F183BB0 46 72 65 65 46 72 65 65 46 72 65 65                 FreeFreeFree    

--memory-breakpoint__ 159071 : Memory at 0x0x7f043f0c3800, size 0x7C = 124
   +0 0x00007F043F0C3800 20 41 B8 48 04 7F 00 00 20 D4 01 3F 04 7F 00 00      A.H... ..?...
  +16 0x00007F043F0C3810 00 00 00 00 00 00 00 00 E0 EF 9D 48 04 7F 00 00     ...........H...
  +32 0x00007F043F0C3820 30 72 65 65 00 00 00 00 00 00 00 00 00 00 00 00     0ree............
  +48 0x00007F043F0C3830 00 00 00 00 00 00 00 00 40 64 13 3F 04 7F 00 00     ........@d.?...

--memory-breakpoint__ 159070 : Memory at 0x0x7f043f01d420, size 0x3C = 60
   +0 0x00007F043F01D420 C8 0C FF 29 04 7F 00 00 00 38 0C 3F 04 7F 00 00     ...)....8.?...
  +16 0x00007F043F01D430 EC 01 00 00 46 72 65 65 20 6C 0E 3F 04 7F 00 00     ....Free l.?...
  +32 0x00007F043F01D440 E0 EF 9D 48 04 7F 00 00 C0 E6 9D 48 04 7F 00 00     ...H......H...
  +48 0x00007F043F01D450 46 72 65 65 46 72 65 65 46 72 65 65                 FreeFreeFree    

--memory-breakpoint__ 159050 : Memory at 0x0x7f043f14b4e0, size 0x21C = 540
   +0 0x00007F043F14B4E0 01 00 00 00 46 72 65 65 80 70 02 3F 04 7F 00 00     ....Free.p.?...
  +16 0x00007F043F14B4F0 60 6C 02 3F 04 7F 00 00 00 6D 02 3F 04 7F 00 00     `l.?....m.?...
  +32 0x00007F043F14B500 A0 78 02 3F 04 7F 00 00 80 6F 02 3F 04 7F 00 00     .x.?....o.?...
  +48 0x00007F043F14B510 E0 6E 02 3F 04 7F 00 00 40 6E 02 3F 04 7F 00 00     .n.?...@n.?...

--memory-breakpoint__ 159048 : Memory at 0x0x7f043f136300, size 0x7C = 124
   +0 0x00007F043F136300 01 00 00 00 01 00 00 00 01 00 00 00 FF FF 00 00     ................
  +16 0x00007F043F136310 00 00 00 00 00 00 65 65 00 00 00 00 00 00 F0 3F     ......ee.......?
  +32 0x00007F043F136320 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00     ................
  +48 0x00007F043F136330 00 00 00 00 00 00 F0 3F 00 00 00 00 00 00 00 00     .......?........

--memory-breakpoint__ 159025 : Memory at 0x0x7f043f0814e0, size 0x3C = 60
   +0 0x00007F043F0814E0 01 00 00 00 1C 14 00 00 C0 E6 9D 48 04 7F 00 00     ...........H...
  +16 0x00007F043F0814F0 00 00 00 00 7F 02 00 00 E9 00 00 00 94 02 00 00     ...............
  +32 0x00007F043F081500 00 00 00 00 7F 02 00 00 E9 00 00 00 94 02 00 00     ...............
  +48 0x00007F043F081510 46 72 65 65 46 72 65 65 46 72 65 65                 FreeFreeFree    

--memory-breakpoint__ 159024 : Memory at 0x0x7f043f183be0, size 0x1C = 28
   +0 0x00007F043F183BE0 01 00 00 00 46 72 65 65 E0 14 08 3F 04 7F 00 00     ....Free...?...
  +16 0x00007F043F183BF0 46 72 65 65 46 72 65 65 46 72 65 65                 FreeFreeFree    

--memory-breakpoint__ 159017 : Memory at 0x0x7f043f1838e0, size 0x1C = 28
   +0 0x00007F043F1838E0 E0 EF 9D 48 04 7F 00 00 46 72 65 65 46 72 65 65     ...H...FreeFree
  +16 0x00007F043F1838F0 46 72 65 65 46 72 65 65 46 72 65 65                 FreeFreeFree    

--memory-breakpoint__ 158991 : Memory at 0x0x7f043f01d720, size 0x3C = 60
   +0 0x00007F043F01D720 01 00 00 00 46 72 65 65 F0 59 FA 69 89 55 00 00     ....Free.Y.i.U..
  +16 0x00007F043F01D730 00 00 65 65 23 9A 36 C1 80 5A 02 3F 04 7F 00 00     ..ee#.6..Z.?...
  +32 0x00007F043F01D740 00 00 00 00 46 72 65 65 46 72 65 65 46 72 65 65     ....FreeFreeFree
  +48 0x00007F043F01D750 46 72 65 65 46 72 65 65 46 72 65 65                 FreeFreeFree    

*** TOO MANY LEAKS (59424) TO LIST THEM ALL
****************** PANIC: Heap leaks detected!

Thanks.


Re: Heap leak reported when using OpenCV in U++ Application. [message #61954 is a reply to message #61953] Tue, 24 March 2026 10:26 Go to previous message
Oblivion is currently offline  Oblivion
Messages: 1266
Registered: August 2007
Senior Contributor
Hi,
* Without using OpenCV → no heap leak
* With a simple OpenCV `cv::Mat` → heap leak appears
* Even with larger code, the reported leak size remains the same
This is usually a signature of leak in the library (in this case OpenCV) itself.
It might be that you are not freeing what you've allocated before, or some probably a bug deep in the library itself.
If it is an OpenCV upstream issue which we can't fix, we use the functions to silence to leaks detector of U++. You can find them here.

Best regards,
Oblivion


Previous Topic: DragAndDrop doesn't work on Fedora 42
Next Topic: Add compilable testcases for nontrivial problems!
Goto Forum:
  


Current Time: Wed May 06 00:54:00 GMT+2 2026

Total time taken to generate the page: 0.01151 seconds