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)