Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Memory leak in RGB2Lab

There is a memory leak when using RBG2Lab. Is this an issue with OpenCV? The version is 3.4.11.

// lab.cpp
#include <opencv2/imgproc/imgproc.hpp>

int main()
{
  cv::Mat in = cv::Mat::zeros(1, 1, CV_8UC3);
  cv::Mat lab;
  cv::cvtColor(in, lab, CV_RGB2Lab);
}

Compile: g++ `pkg-config --libs --cflags opencv` lab.cpp

Run: valgrind --leak-check=full a.out

Output:

==38352== Memcheck, a memory error detector
==38352== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==38352== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright info
==38352== Command: a.out
==38352== 
==38352== 
==38352== HEAP SUMMARY:
==38352==     in use at exit: 4,716,918 bytes in 321 blocks
==38352==   total heap usage: 5,506 allocs, 5,185 frees, 5,396,766 bytes allocated
==38352== 
==38352== 16,456 bytes in 1 blocks are possibly lost in loss record 101 of 109
==38352==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78AFB0E: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78B16E0: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x400B5C: main (in /home/bstolk/work.cld4/sensor/ProductProcessors/ppImageFilter/tests/a.out)
==38352== 
==38352== 16,456 bytes in 1 blocks are possibly lost in loss record 102 of 109
==38352==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78AFB0E: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78B19B1: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x400B5C: main (in /home/bstolk/work.cld4/sensor/ProductProcessors/ppImageFilter/tests/a.out)
==38352== 
==38352== 16,456 bytes in 1 blocks are possibly lost in loss record 103 of 109
==38352==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78AFB0E: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78B19C2: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x400B5C: main (in /home/bstolk/work.cld4/sensor/ProductProcessors/ppImageFilter/tests/a.out)
==38352== 
==38352== 147,528 bytes in 1 blocks are possibly lost in loss record 104 of 109
==38352==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78B21AE: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x400B5C: main (in /home/bstolk/work.cld4/sensor/ProductProcessors/ppImageFilter/tests/a.out)
==38352== 
==38352== 262,216 bytes in 1 blocks are possibly lost in loss record 105 of 109
==38352==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78B25FB: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x400B5C: main (in /home/bstolk/work.cld4/sensor/ProductProcessors/ppImageFilter/tests/a.out)
==38352== 
==38352== 262,216 bytes in 1 blocks are possibly lost in loss record 106 of 109
==38352==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78B260D: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x400B5C: main (in /home/bstolk/work.cld4/sensor/ProductProcessors/ppImageFilter/tests/a.out)
==38352== 
==38352== 524,360 bytes in 1 blocks are possibly lost in loss record 107 of 109
==38352==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78B261F: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x400B5C: main (in /home/bstolk/work.cld4/sensor/ProductProcessors/ppImageFilter/tests/a.out)
==38352== 
==38352== 1,725,048 bytes in 1 blocks are possibly lost in loss record 108 of 109
==38352==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78B121E: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x400B5C: main (in /home/bstolk/work.cld4/sensor/ProductProcessors/ppImageFilter/tests/a.out)
==38352== 
==38352== 1,725,048 bytes in 1 blocks are possibly lost in loss record 109 of 109
==38352==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78B1230: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x400B5C: main (in /home/bstolk/work.cld4/sensor/ProductProcessors/ppImageFilter/tests/a.out)
==38352== 
==38352== LEAK SUMMARY:
==38352==    definitely lost: 0 bytes in 0 blocks
==38352==    indirectly lost: 0 bytes in 0 blocks
==38352==      possibly lost: 4,695,784 bytes in 9 blocks
==38352==    still reachable: 632 bytes in 5 blocks
==38352==                       of which reachable via heuristic:
==38352==                         stdstring          : 8,662 bytes in 135 blocks
==38352==         suppressed: 20,502 bytes in 307 blocks
==38352== Reachable blocks (those to which a pointer was found) are not shown.
==38352== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==38352== 
==38352== For counts of detected and suppressed errors, rerun with: -v
==38352== ERROR SUMMARY: 9 errors from 9 contexts (suppressed: 4 from 4)

Memory leak in RGB2Lab

There is a memory leak when using RBG2Lab. Is this an issue with OpenCV? The version is 3.4.11.

// lab.cpp
#include <opencv2/imgproc/imgproc.hpp>

int main()
{
  cv::Mat in = cv::Mat::zeros(1, 1, CV_8UC3);
  cv::Mat lab;
  cv::cvtColor(in, lab, CV_RGB2Lab);
}

Compile: g++ `pkg-config --libs --cflags opencv` lab.cpp

Run: valgrind --leak-check=full a.out

Output:

==38352== Memcheck, a memory error detector
==38352== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==38352== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright info
==38352== Command: a.out
==38352== 
==38352== 
==38352== HEAP SUMMARY:
==38352==     in use at exit: 4,716,918 bytes in 321 blocks
==38352==   total heap usage: 5,506 allocs, 5,185 frees, 5,396,766 bytes allocated
==38352== 
==38352== 16,456 bytes in 1 blocks are possibly lost in loss record 101 of 109
==38352==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78AFB0E: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78B16E0: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x400B5C: main (in /home/bstolk/work.cld4/sensor/ProductProcessors/ppImageFilter/tests/a.out)
a.out)
==38352== 
==38352== 16,456 bytes in 1 blocks are possibly lost in loss record 102 of 109
==38352==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78AFB0E: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78B19B1: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x400B5C: main (in /home/bstolk/work.cld4/sensor/ProductProcessors/ppImageFilter/tests/a.out)
a.out)
==38352== 
==38352== 16,456 bytes in 1 blocks are possibly lost in loss record 103 of 109
==38352==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78AFB0E: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78B19C2: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x400B5C: main (in /home/bstolk/work.cld4/sensor/ProductProcessors/ppImageFilter/tests/a.out)
a.out)
==38352== 
==38352== 147,528 bytes in 1 blocks are possibly lost in loss record 104 of 109
==38352==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78B21AE: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x400B5C: main (in /home/bstolk/work.cld4/sensor/ProductProcessors/ppImageFilter/tests/a.out)
a.out)
==38352== 
==38352== 262,216 bytes in 1 blocks are possibly lost in loss record 105 of 109
==38352==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78B25FB: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x400B5C: main (in /home/bstolk/work.cld4/sensor/ProductProcessors/ppImageFilter/tests/a.out)
a.out)
==38352== 
==38352== 262,216 bytes in 1 blocks are possibly lost in loss record 106 of 109
==38352==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78B260D: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x400B5C: main (in /home/bstolk/work.cld4/sensor/ProductProcessors/ppImageFilter/tests/a.out)
a.out)
==38352== 
==38352== 524,360 bytes in 1 blocks are possibly lost in loss record 107 of 109
==38352==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78B261F: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x400B5C: main (in /home/bstolk/work.cld4/sensor/ProductProcessors/ppImageFilter/tests/a.out)
a.out)
==38352== 
==38352== 1,725,048 bytes in 1 blocks are possibly lost in loss record 108 of 109
==38352==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78B121E: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x400B5C: main (in /home/bstolk/work.cld4/sensor/ProductProcessors/ppImageFilter/tests/a.out)
a.out)
==38352== 
==38352== 1,725,048 bytes in 1 blocks are possibly lost in loss record 109 of 109
==38352==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78B1230: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x400B5C: main (in /home/bstolk/work.cld4/sensor/ProductProcessors/ppImageFilter/tests/a.out)
a.out)
==38352== 
==38352== LEAK SUMMARY:
==38352==    definitely lost: 0 bytes in 0 blocks
==38352==    indirectly lost: 0 bytes in 0 blocks
==38352==      possibly lost: 4,695,784 bytes in 9 blocks
==38352==    still reachable: 632 bytes in 5 blocks
==38352==                       of which reachable via heuristic:
==38352==                         stdstring          : 8,662 bytes in 135 blocks
==38352==         suppressed: 20,502 bytes in 307 blocks
==38352== Reachable blocks (those to which a pointer was found) are not shown.
==38352== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==38352== 
==38352== For counts of detected and suppressed errors, rerun with: -v
==38352== ERROR SUMMARY: 9 errors from 9 contexts (suppressed: 4 from 4)

Memory leak in RGB2Lab

There is a memory leak when using RBG2Lab. Is this an issue with OpenCV? The version is 3.4.11.

// lab.cpp
#include <opencv2/imgproc/imgproc.hpp>

int main()
{
  cv::Mat in = cv::Mat::zeros(1, 1, CV_8UC3);
  cv::Mat lab;
  cv::cvtColor(in, lab, CV_RGB2Lab);
}

Compile: g++ `pkg-config --libs --cflags opencv` lab.cpp

Run: valgrind --leak-check=full a.out

Output:

==38352== Memcheck, a memory error detector
==38352== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==38352== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright info
==38352== Command: a.out
==38352== 
==38352== 
==38352== HEAP SUMMARY:
==38352==     in use at exit: 4,716,918 bytes in 321 blocks
==38352==   total heap usage: 5,506 allocs, 5,185 frees, 5,396,766 bytes allocated
==38352== 
==38352== 16,456 bytes in 1 blocks are possibly lost in loss record 101 of 109
==38352==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78AFB0E: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78B16E0: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x400B5C: main (in a.out)
==38352== 
==38352== 16,456 bytes in 1 blocks are possibly lost in loss record 102 of 109
==38352==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78AFB0E: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78B19B1: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x400B5C: main (in a.out)
==38352== 
==38352== 16,456 bytes in 1 blocks are possibly lost in loss record 103 of 109
==38352==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78AFB0E: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78B19C2: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x400B5C: main (in a.out)
==38352== 
==38352== 147,528 bytes in 1 blocks are possibly lost in loss record 104 of 109
==38352==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78B21AE: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x400B5C: main (in a.out)
==38352== 
==38352== 262,216 bytes in 1 blocks are possibly lost in loss record 105 of 109
==38352==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78B25FB: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x400B5C: main (in a.out)
==38352== 
==38352== 262,216 bytes in 1 blocks are possibly lost in loss record 106 of 109
==38352==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78B260D: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x400B5C: main (in a.out)
==38352== 
==38352== 524,360 bytes in 1 blocks are possibly lost in loss record 107 of 109
==38352==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78B261F: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x400B5C: main (in a.out)
==38352== 
==38352== 1,725,048 bytes in 1 blocks are possibly lost in loss record 108 of 109
==38352==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78B121E: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x400B5C: main (in a.out)
==38352== 
==38352== 1,725,048 bytes in 1 blocks are possibly lost in loss record 109 of 109
==38352==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78B1230: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x400B5C: main (in a.out)
==38352== 
==38352== LEAK SUMMARY:
==38352==    definitely lost: 0 bytes in 0 blocks
==38352==    indirectly lost: 0 bytes in 0 blocks
==38352==      possibly lost: 4,695,784 bytes in 9 blocks
==38352==    still reachable: 632 bytes in 5 blocks
==38352==                       of which reachable via heuristic:
==38352==                         stdstring          : 8,662 bytes in 135 blocks
==38352==         suppressed: 20,502 bytes in 307 blocks
==38352== Reachable blocks (those to which a pointer was found) are not shown.
==38352== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==38352== 
==38352== For counts of detected and suppressed errors, rerun with: -v
==38352== ERROR SUMMARY: 9 errors from 9 contexts (suppressed: 4 from 4)

The output of cv::getBuildInformation():

General configuration for OpenCV 3.4.11 =====================================
  Version control:               unknown

  Platform:
    Timestamp:                   2020-07-29T07:23:02Z
    Host:                        Linux 2.6.32-754.10.1.el6.x86_64 x86_64
    CMake:                       2.8.12.2
    CMake generator:             Unix Makefiles
    CMake build tool:            /opt/rh/devtoolset-6/root/usr/bin/gmake
    Configuration:               Release

  CPU/HW features:
    Baseline:                    SSE SSE2 SSE3
      requested:                 SSE3
    Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
      requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
      SSE4_1 (16 files):         + SSSE3 SSE4_1
      SSE4_2 (2 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
      FP16 (1 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
      AVX (6 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
      AVX2 (30 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
      AVX512_SKX (7 files):      + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX

  C/C++:
    Built as dynamic libs?:      YES
    C++11:                       YES
    C++ Compiler:                /opt/rh/devtoolset-6/root/usr/bin/c++  (ver 6.3.1)
    C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-psabi -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
    C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-psabi -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
    C Compiler:                  /opt/rh/devtoolset-6/root/usr/bin/cc
    C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-psabi -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
    C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-psabi -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
    Linker flags (Release):      -Wl,--gc-sections -Wl,--as-needed  
    Linker flags (Debug):        -Wl,--gc-sections -Wl,--as-needed  
    ccache:                      NO
    Precompiled headers:         NO
    Extra dependencies:          dl m pthread rt
    3rdparty dependencies:

  OpenCV modules:
    To be built:                 calib3d core dnn features2d flann highgui imgcodecs imgproc ml objdetect photo python2 shape stitching superres ts video videoio videostab
    Disabled:                    java_bindings_generator world
    Disabled by dependency:      -
    Unavailable:                 cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java js python3 viz
    Applications:                tests perf_tests apps
    Documentation:               doxygen
    Non-free algorithms:         NO

  GUI: 

  Media I/O: 
    ZLib:                        /usr/lib64/libz.so (ver 1.2.3)
    JPEG:                        build-libjpeg-turbo (ver 2.0.5-62)
    PNG:                         build (ver 1.6.37)
    TIFF:                        build (ver 42 - 4.0.10)
    HDR:                         YES
    SUNRASTER:                   YES
    PXM:                         YES

  Video I/O:

  Parallel framework:            pthreads

  Trace:                         YES (built-in)

  Other third-party libraries:
    Intel IPP:                   2018.0.2 [2018.0.2]
           at:                   /opt/intel/compilers_and_libraries_2018.2.199/linux/ipp
       linked:                   static
    Intel IPP IW:                sources (2020.0.0)
              at:                /localhome/[user]/rpmbuild/BUILD/opencv-3.4.11/build/3rdparty/ippicv/ippicv_lnx/iw/
    Lapack:                      NO
    Eigen:                       NO
    Custom HAL:                  NO
    Protobuf:                    build (3.5.1)

  OpenCL:                        YES (no extra features)
    Include path:                /localhome/[user]/rpmbuild/BUILD/opencv-3.4.11/3rdparty/include/opencl/1.2
    Link libraries:              Dynamic load

  Python 2:
    Interpreter:                 /opt/python27/bin/python2.7 (ver 2.7.12)
    Libraries:                   /opt/python27/lib/libpython2.7.so (ver 2.7.12)
    numpy:                       /opt/python27/lib/python2.7/site-packages/numpy/core/include (ver 1.14.2)
    install path:                lib/python2.7/site-packages/cv2/python-2.7

  Python (for build):            /opt/python27/bin/python2.7

  Install to:                    /usr
-----------------------------------------------------------------

Memory leak in RGB2Lab

There is a memory leak when using RBG2Lab. Is this an issue with OpenCV? The version is 3.4.11.

// lab.cpp
#include <opencv2/imgproc/imgproc.hpp>

int main()
{
  cv::Mat in = cv::Mat::zeros(1, 1, CV_8UC3);
  cv::Mat lab;
  cv::cvtColor(in, lab, CV_RGB2Lab);
}

Compile: g++ `pkg-config --libs --cflags opencv` lab.cpp

Run: valgrind --leak-check=full a.out

Output:

==38352== ==2689== Memcheck, a memory error detector
==38352== ==2689== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==38352== ==2689== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright info
==38352== ==2689== Command: a.out
==38352== 
==38352== 
==38352== lab
==2689== 
==2689== 
==2689== HEAP SUMMARY:
==38352== ==2689==     in use at exit: 4,716,918 bytes in 321 blocks
==38352== ==2689==   total heap usage: 5,506 allocs, 5,185 frees, 5,396,766 bytes allocated
==38352== 
==38352== ==2689== 
==2689== 16,456 bytes in 1 blocks are possibly lost in loss record 101 of 109
==38352== ==2689==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: ==2689==    by 0x93164D0: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78AFB0E: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78B16E0: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: (alloc.cpp:150)
==2689==    by 0x76678CE: allocSingleton<float> (private.hpp:153)
==2689==    by 0x76678CE: splineBuild(cv::softfloat const*, unsigned long) [clone .constprop.37] (color_lab.cpp:22)
==2689==    by 0x7669300: cv::initLabTabs() (color_lab.cpp:1221)
==2689==    by 0x7679DD4: RGB2Lab_b (color_lab.cpp:1547)
==2689==    by 0x7679DD4: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: (color_lab.cpp:4176)
==2689==    by 0x767F4AC: cv::cvtColorBGR2Lab(cv::_InputArray const&, cv::_OutputArray const&, bool, bool) (color_lab.cpp:4668)
==2689==    by 0x76DDE71: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352== (color.cpp:270)
==2689==    by 0x400B5C: main (in a.out)
==38352== 
==38352== ==2689== 
==2689== 16,456 bytes in 1 blocks are possibly lost in loss record 102 of 109
==38352== ==2689==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: ==2689==    by 0x93164D0: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78AFB0E: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78B19B1: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: (alloc.cpp:150)
==2689==    by 0x76678CE: allocSingleton<float> (private.hpp:153)
==2689==    by 0x76678CE: splineBuild(cv::softfloat const*, unsigned long) [clone .constprop.37] (color_lab.cpp:22)
==2689==    by 0x76695D4: cv::initLabTabs() (color_lab.cpp:1231)
==2689==    by 0x7679DD4: RGB2Lab_b (color_lab.cpp:1547)
==2689==    by 0x7679DD4: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: (color_lab.cpp:4176)
==2689==    by 0x767F4AC: cv::cvtColorBGR2Lab(cv::_InputArray const&, cv::_OutputArray const&, bool, bool) (color_lab.cpp:4668)
==2689==    by 0x76DDE71: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352== (color.cpp:270)
==2689==    by 0x400B5C: main (in a.out)
==38352== 
==38352== ==2689== 
==2689== 16,456 bytes in 1 blocks are possibly lost in loss record 103 of 109
==38352== ==2689==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: ==2689==    by 0x93164D0: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78AFB0E: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78B19C2: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: (alloc.cpp:150)
==2689==    by 0x76678CE: allocSingleton<float> (private.hpp:153)
==2689==    by 0x76678CE: splineBuild(cv::softfloat const*, unsigned long) [clone .constprop.37] (color_lab.cpp:22)
==2689==    by 0x76695E5: cv::initLabTabs() (color_lab.cpp:1232)
==2689==    by 0x7679DD4: RGB2Lab_b (color_lab.cpp:1547)
==2689==    by 0x7679DD4: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: (color_lab.cpp:4176)
==2689==    by 0x767F4AC: cv::cvtColorBGR2Lab(cv::_InputArray const&, cv::_OutputArray const&, bool, bool) (color_lab.cpp:4668)
==2689==    by 0x76DDE71: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352== (color.cpp:270)
==2689==    by 0x400B5C: main (in a.out)
==38352== 
==38352== ==2689== 
==2689== 147,528 bytes in 1 blocks are possibly lost in loss record 104 of 109
==38352== ==2689==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: ==2689==    by 0x93164D0: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78B21AE: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: (alloc.cpp:150)
==2689==    by 0x7669DDD: allocSingleton<int> (private.hpp:153)
==2689==    by 0x7669DDD: initLUTforABXZ (color_lab.cpp:1062)
==2689==    by 0x7669DDD: cv::initLabTabs() (color_lab.cpp:1285)
==2689==    by 0x7679DD4: RGB2Lab_b (color_lab.cpp:1547)
==2689==    by 0x7679DD4: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: (color_lab.cpp:4176)
==2689==    by 0x767F4AC: cv::cvtColorBGR2Lab(cv::_InputArray const&, cv::_OutputArray const&, bool, bool) (color_lab.cpp:4668)
==2689==    by 0x76DDE71: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352== (color.cpp:270)
==2689==    by 0x400B5C: main (in a.out)
==38352== 
==38352== ==2689== 
==2689== 262,216 bytes in 1 blocks are possibly lost in loss record 105 of 109
==38352== ==2689==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: ==2689==    by 0x93164D0: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78B25FB: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: (alloc.cpp:150)
==2689==    by 0x766A001: allocSingleton<int> (private.hpp:153)
==2689==    by 0x766A001: initLUTforLUV (color_lab.cpp:1028)
==2689==    by 0x766A001: cv::initLabTabs() (color_lab.cpp:1293)
==2689==    by 0x7679DD4: RGB2Lab_b (color_lab.cpp:1547)
==2689==    by 0x7679DD4: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: (color_lab.cpp:4176)
==2689==    by 0x767F4AC: cv::cvtColorBGR2Lab(cv::_InputArray const&, cv::_OutputArray const&, bool, bool) (color_lab.cpp:4668)
==2689==    by 0x76DDE71: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352== (color.cpp:270)
==2689==    by 0x400B5C: main (in a.out)
==38352== 
==38352== ==2689== 
==2689== 262,216 bytes in 1 blocks are possibly lost in loss record 106 of 109
==38352== ==2689==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: ==2689==    by 0x93164D0: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78B260D: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: (alloc.cpp:150)
==2689==    by 0x766A010: allocSingleton<int> (private.hpp:153)
==2689==    by 0x766A010: initLUTforLUV (color_lab.cpp:1029)
==2689==    by 0x766A010: cv::initLabTabs() (color_lab.cpp:1293)
==2689==    by 0x7679DD4: RGB2Lab_b (color_lab.cpp:1547)
==2689==    by 0x7679DD4: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: (color_lab.cpp:4176)
==2689==    by 0x767F4AC: cv::cvtColorBGR2Lab(cv::_InputArray const&, cv::_OutputArray const&, bool, bool) (color_lab.cpp:4668)
==2689==    by 0x76DDE71: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352== (color.cpp:270)
==2689==    by 0x400B5C: main (in a.out)
==38352== 
==38352== ==2689== 
==2689== 524,360 bytes in 1 blocks are possibly lost in loss record 107 of 109
==38352== ==2689==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: ==2689==    by 0x93164D0: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78B261F: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: (alloc.cpp:150)
==2689==    by 0x766A022: allocSingleton<long long int> (private.hpp:153)
==2689==    by 0x766A022: initLUTforLUV (color_lab.cpp:1030)
==2689==    by 0x766A022: cv::initLabTabs() (color_lab.cpp:1293)
==2689==    by 0x7679DD4: RGB2Lab_b (color_lab.cpp:1547)
==2689==    by 0x7679DD4: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: (color_lab.cpp:4176)
==2689==    by 0x767F4AC: cv::cvtColorBGR2Lab(cv::_InputArray const&, cv::_OutputArray const&, bool, bool) (color_lab.cpp:4668)
==2689==    by 0x76DDE71: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352== (color.cpp:270)
==2689==    by 0x400B5C: main (in a.out)
==38352== 
==38352== ==2689== 
==2689== 1,725,048 bytes in 1 blocks are possibly lost in loss record 108 of 109
==38352== ==2689==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: ==2689==    by 0x93164D0: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78B121E: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: (alloc.cpp:150)
==2689==    by 0x7668F04: allocSingleton<short int> (private.hpp:153)
==2689==    by 0x7668F04: initLUTforLABLUVs16 (color_lab.cpp:1192)
==2689==    by 0x7668F04: cv::initLabTabs() (color_lab.cpp:1300)
==2689==    by 0x7679DD4: RGB2Lab_b (color_lab.cpp:1547)
==2689==    by 0x7679DD4: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: (color_lab.cpp:4176)
==2689==    by 0x767F4AC: cv::cvtColorBGR2Lab(cv::_InputArray const&, cv::_OutputArray const&, bool, bool) (color_lab.cpp:4668)
==2689==    by 0x76DDE71: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352== (color.cpp:270)
==2689==    by 0x400B5C: main (in a.out)
==38352== 
==38352== ==2689== 
==2689== 1,725,048 bytes in 1 blocks are possibly lost in loss record 109 of 109
==38352== ==2689==    at 0x4A08178: malloc (vg_replace_malloc.c:298)
==38352==    by 0xA5E5900: ==2689==    by 0x93164D0: cv::fastMalloc(unsigned long) (in /usr/lib64/libopencv_core.so.3.4.11)
==38352==    by 0x78B1230: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78C4AFC: (alloc.cpp:150)
==2689==    by 0x7668F11: allocSingleton<short int> (private.hpp:153)
==2689==    by 0x7668F11: initLUTforLABLUVs16 (color_lab.cpp:1193)
==2689==    by 0x7668F11: cv::initLabTabs() (color_lab.cpp:1300)
==2689==    by 0x7679DD4: RGB2Lab_b (color_lab.cpp:1547)
==2689==    by 0x7679DD4: cv::hal::cvtBGRtoLab(unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, int, int, bool, bool, bool) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x78CA0EC: ??? (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352==    by 0x796D811: (color_lab.cpp:4176)
==2689==    by 0x767F4AC: cv::cvtColorBGR2Lab(cv::_InputArray const&, cv::_OutputArray const&, bool, bool) (color_lab.cpp:4668)
==2689==    by 0x76DDE71: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib64/libopencv_imgproc.so.3.4.11)
==38352== (color.cpp:270)
==2689==    by 0x400B5C: main (in a.out)
==38352== 
==38352== ==2689== 
==2689== LEAK SUMMARY:
==38352== ==2689==    definitely lost: 0 bytes in 0 blocks
==38352== ==2689==    indirectly lost: 0 bytes in 0 blocks
==38352== ==2689==      possibly lost: 4,695,784 bytes in 9 blocks
==38352== ==2689==    still reachable: 632 0 bytes in 5 0 blocks
==38352== ==2689==                       of which reachable via heuristic:
==38352== ==2689==                         stdstring          : 8,662 bytes in 135 blocks
==38352== ==2689==         suppressed: 20,502 21,134 bytes in 307 312 blocks
==38352== Reachable blocks (those to which a pointer was found) are not shown.
==38352== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==38352== 
==38352== ==2689== 
==2689== For counts of detected and suppressed errors, rerun with: -v
==38352== ==2689== ERROR SUMMARY: 9 errors from 9 contexts (suppressed: 4 from 4)

The output of cv::getBuildInformation():

General configuration for OpenCV 3.4.11 =====================================
  Version control:               unknown

  Platform:
    Timestamp:                   2020-07-29T07:23:02Z
    Host:                        Linux 2.6.32-754.10.1.el6.x86_64 x86_64
    CMake:                       2.8.12.2
    CMake generator:             Unix Makefiles
    CMake build tool:            /opt/rh/devtoolset-6/root/usr/bin/gmake
    Configuration:               Release

  CPU/HW features:
    Baseline:                    SSE SSE2 SSE3
      requested:                 SSE3
    Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
      requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
      SSE4_1 (16 files):         + SSSE3 SSE4_1
      SSE4_2 (2 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
      FP16 (1 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
      AVX (6 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
      AVX2 (30 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
      AVX512_SKX (7 files):      + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX

  C/C++:
    Built as dynamic libs?:      YES
    C++11:                       YES
    C++ Compiler:                /opt/rh/devtoolset-6/root/usr/bin/c++  (ver 6.3.1)
    C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-psabi -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
    C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-psabi -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
    C Compiler:                  /opt/rh/devtoolset-6/root/usr/bin/cc
    C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-psabi -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
    C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-psabi -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
    Linker flags (Release):      -Wl,--gc-sections -Wl,--as-needed  
    Linker flags (Debug):        -Wl,--gc-sections -Wl,--as-needed  
    ccache:                      NO
    Precompiled headers:         NO
    Extra dependencies:          dl m pthread rt
    3rdparty dependencies:

  OpenCV modules:
    To be built:                 calib3d core dnn features2d flann highgui imgcodecs imgproc ml objdetect photo python2 shape stitching superres ts video videoio videostab
    Disabled:                    java_bindings_generator world
    Disabled by dependency:      -
    Unavailable:                 cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java js python3 viz
    Applications:                tests perf_tests apps
    Documentation:               doxygen
    Non-free algorithms:         NO

  GUI: 

  Media I/O: 
    ZLib:                        /usr/lib64/libz.so (ver 1.2.3)
    JPEG:                        build-libjpeg-turbo (ver 2.0.5-62)
    PNG:                         build (ver 1.6.37)
    TIFF:                        build (ver 42 - 4.0.10)
    HDR:                         YES
    SUNRASTER:                   YES
    PXM:                         YES

  Video I/O:

  Parallel framework:            pthreads

  Trace:                         YES (built-in)

  Other third-party libraries:
    Intel IPP:                   2018.0.2 [2018.0.2]
           at:                   /opt/intel/compilers_and_libraries_2018.2.199/linux/ipp
       linked:                   static
    Intel IPP IW:                sources (2020.0.0)
              at:                /localhome/[user]/rpmbuild/BUILD/opencv-3.4.11/build/3rdparty/ippicv/ippicv_lnx/iw/
    Lapack:                      NO
    Eigen:                       NO
    Custom HAL:                  NO
    Protobuf:                    build (3.5.1)

  OpenCL:                        YES (no extra features)
    Include path:                /localhome/[user]/rpmbuild/BUILD/opencv-3.4.11/3rdparty/include/opencl/1.2
    Link libraries:              Dynamic load

  Python 2:
    Interpreter:                 /opt/python27/bin/python2.7 (ver 2.7.12)
    Libraries:                   /opt/python27/lib/libpython2.7.so (ver 2.7.12)
    numpy:                       /opt/python27/lib/python2.7/site-packages/numpy/core/include (ver 1.14.2)
    install path:                lib/python2.7/site-packages/cv2/python-2.7

  Python (for build):            /opt/python27/bin/python2.7

  Install to:                    /usr
-----------------------------------------------------------------