Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Possible memory leak in cvtColor

Dear all,

I'm running some tests with cvtColor and valgrind reports a memory leak.

Some information about the environment:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.2 LTS
Release:    14.04
Codename:   trusty

$ uname --all
Linux <hidden> 3.16.0-34-generic #47~14.04.1-Ubuntu SMP Fri Apr 10 17:49:16 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

$ pkg-config --modversion opencv
2.4.8

$ g++ --version
g++ (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ valgrind --version
valgrind-3.10.0.SVN

This is a short standalone sample:

$ cat test.cpp 
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>

int main()
{
    std::cout << cv::getBuildInformation() << std::endl;

    cv::Mat src = cv::Mat::zeros(5, 5, CV_8UC3);
    cv::Mat dst;

    cv::cvtColor( src, dst, CV_BGR2GRAY );
}


$ g++ -Wall -Wextra -Werror -Weffc++ -ansi -pedantic -O2 test.cpp -o test  $(pkg-config --cflags --libs opencv) 
<nothing printed on screen>

And the output from valgrind:

$ valgrind --leak-check=full ./test 
==15342== Memcheck, a memory error detector
==15342== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==15342== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright info
==15342== Command: ./test
==15342== 

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

  Platform:
    Host:                        Linux 3.2.0-58-generic x86_64
    CMake:                       2.8.12.2
    CMake generator:             Unix Makefiles
    CMake build tool:            /usr/bin/make
    Configuration:               Release

  C/C++:
    Built as dynamic libs?:      YES
    C++ Compiler:                /usr/bin/x86_64-linux-gnu-g++  (ver 4.8.2)
    C++ flags (Release):         -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2    -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -ffunction-sections -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security  -DNDEBUG
    C++ flags (Debug):           -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2    -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG
    C Compiler:                  /usr/bin/x86_64-linux-gnu-gcc
    C flags (Release):           -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2    -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -ffunction-sections -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security  -DNDEBUG
    C flags (Debug):             -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2    -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG
    Linker flags (Release):      -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now
    Linker flags (Debug):        -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now
    Precompiled headers:         YES

  OpenCV modules:
    To be built:                 core flann imgproc highgui features2d calib3d ml objdetect video contrib legacy photo gpu java ocl python stitching superres ts videostab
    Disabled:                    world
    Disabled by dependency:      -
    Unavailable:                 androidcamera dynamicuda

  GUI: 
    QT:                          NO
    GTK+ 2.x:                    YES (ver 2.24.22)
    GThread :                    YES (ver 2.39.90)
    GtkGlExt:                    YES (ver 1.2.0)
    OpenGL support:              YES (/usr/lib/x86_64-linux-gnu/libGLU.so /usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libSM.so /usr/lib/x86_64-linux-gnu/libICE.so /usr/lib/x86_64-linux-gnu/libX11.so /usr/lib/x86_64-linux-gnu/libXext.so)

  Media I/O: 
    ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.8)
    JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver )
    PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.2.50)
    TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 - 4.0.3)
    JPEG 2000:                   /usr/lib/x86_64-linux-gnu/libjasper.so (ver 1.900.1)
    OpenEXR:                     /usr/lib/x86_64-linux-gnu/libImath.so /usr/lib/x86_64-linux-gnu/libIlmImf.so /usr/lib/x86_64-linux-gnu/libIex.so /usr/lib/x86_64-linux-gnu/libHalf.so /usr/lib/x86_64-linux-gnu/libIlmThread.so (ver 1.6.1)

  Video I/O:
    DC1394 1.x:                  NO
    DC1394 2.x:                  YES (ver 2.2.1)
    FFMPEG:                      YES
      codec:                     YES (ver 54.35.0)
      format:                    YES (ver 54.20.3)
      util:                      YES (ver 52.3.0)
      swscale:                   YES (ver 2.1.1)
      gentoo-style:              YES
    GStreamer:                   NO
    OpenNI:                      NO
    OpenNI PrimeSensor Modules:  NO
    PvAPI:                       NO
    GigEVisionSDK:               NO
    UniCap:                      NO
    UniCap ucil:                 NO
    V4L/V4L2:                    Using libv4l (ver 1.0.1)
    XIMEA:                       NO
    Xine:                        NO

  Other third-party libraries:
    Use IPP:                     NO
    Use Eigen:                   YES (ver 3.2.0)
    Use TBB:                     YES (ver 4.2 interface 7000)
    Use OpenMP:                  NO
    Use GCD                      NO
    Use Concurrency              NO
    Use C=:                      NO
    Use Cuda:                    NO
    Use OpenCL:                  YES

  OpenCL:
    Version:                     dynamic
    Use AMD FFT:                 NO
    Use AMD BLAS:                NO

  Python:
    Interpreter:                 /usr/bin/python2 (ver 2.7.6)
    Libraries:                   /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.6)
    numpy:                       /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.8.0.dev-95f7a46)
    packages path:               lib/python2.7/dist-packages

  Java:
    ant:                         /usr/bin/ant (ver 1.9.3)
    JNI:                         /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include
    Java tests:                  NO

  Documentation:
    Build Documentation:         YES
    Sphinx:                      /usr/bin/sphinx-build (ver 1.2.1)
    PdfLaTeX compiler:           /usr/bin/pdflatex

  Tests and samples:
    Tests:                       NO
    Performance tests:           YES
    C/C++ Examples:              YES

  Install path:                  /usr

  cvconfig.h is in:              /build/buildd/opencv-2.4.8+dfsg1/obj-x86_64-linux-gnu
-----------------------------------------------------------------


==15342== 
==15342== HEAP SUMMARY:
==15342==     in use at exit: 4,616 bytes in 9 blocks
==15342==   total heap usage: 52 allocs, 43 frees, 17,572 bytes allocated
==15342== 
==15342== 3,096 bytes in 3 blocks are possibly lost in loss record 7 of 7
==15342==    at 0x4C2B800: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15342==    by 0x68C923B: ??? (in /usr/lib/libtbb.so.2)
==15342==    by 0x68C95BD: ??? (in /usr/lib/libtbb.so.2)
==15342==    by 0x68C7B02: ??? (in /usr/lib/libtbb.so.2)
==15342==    by 0x68C7359: ??? (in /usr/lib/libtbb.so.2)
==15342==    by 0x68C5800: tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const (in /usr/lib/libtbb.so.2)
==15342==    by 0x4FD9489: cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double) (in /usr/lib/x86_64-linux-gnu/libopencv_core.so.2.4.8)
==15342==    by 0x534E89B: void cv::CvtColorLoop<cv::RGB2Gray<unsigned char> >(cv::Mat const&, cv::Mat&, cv::RGB2Gray<unsigned char> const&) (in /usr/lib/x86_64-linux-gnu/libopencv_imgproc.so.2.4.8)
==15342==    by 0x535BDDD: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib/x86_64-linux-gnu/libopencv_imgproc.so.2.4.8)
==15342==    by 0x400E78: main (in /home/gfolego/projects/test/test)
==15342== 
==15342== LEAK SUMMARY:
==15342==    definitely lost: 0 bytes in 0 blocks
==15342==    indirectly lost: 0 bytes in 0 blocks
==15342==      possibly lost: 3,096 bytes in 3 blocks
==15342==    still reachable: 1,520 bytes in 6 blocks
==15342==         suppressed: 0 bytes in 0 blocks
==15342== Reachable blocks (those to which a pointer was found) are not shown.
==15342== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==15342== 
==15342== For counts of detected and suppressed errors, rerun with: -v
==15342== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

Is this the expected output? What am I missing in order to fix this memory leak?

Thanks and best regards!

Possible memory leak in cvtColorcvtColor with TBB support

Dear all,

I'm running some tests with cvtColor and valgrind reports a memory leak.

Some information about the environment:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.2 LTS
Release:    14.04
Codename:   trusty

$ uname --all
Linux <hidden> 3.16.0-34-generic #47~14.04.1-Ubuntu SMP Fri Apr 10 17:49:16 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

$ pkg-config --modversion opencv
2.4.8

$ g++ --version
g++ (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ valgrind --version
valgrind-3.10.0.SVN

This is a short standalone sample:

$ cat test.cpp 
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>

int main()
{
    std::cout << cv::getBuildInformation() << std::endl;

    cv::Mat src = cv::Mat::zeros(5, 5, CV_8UC3);
    cv::Mat dst;

    cv::cvtColor( src, dst, CV_BGR2GRAY );
}


$ g++ -Wall -Wextra -Werror -Weffc++ -ansi -pedantic -O2 test.cpp -o test  $(pkg-config --cflags --libs opencv) 
<nothing printed on screen>

And the output from valgrind:

$ valgrind --leak-check=full ./test 
==15342== Memcheck, a memory error detector
==15342== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==15342== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright info
==15342== Command: ./test
==15342== 

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

  Platform:
    Host:                        Linux 3.2.0-58-generic x86_64
    CMake:                       2.8.12.2
    CMake generator:             Unix Makefiles
    CMake build tool:            /usr/bin/make
    Configuration:               Release

  C/C++:
    Built as dynamic libs?:      YES
    C++ Compiler:                /usr/bin/x86_64-linux-gnu-g++  (ver 4.8.2)
    C++ flags (Release):         -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2    -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -ffunction-sections -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security  -DNDEBUG
    C++ flags (Debug):           -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2    -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG
    C Compiler:                  /usr/bin/x86_64-linux-gnu-gcc
    C flags (Release):           -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2    -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -ffunction-sections -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security  -DNDEBUG
    C flags (Debug):             -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2    -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG
    Linker flags (Release):      -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now
    Linker flags (Debug):        -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now
    Precompiled headers:         YES

  OpenCV modules:
    To be built:                 core flann imgproc highgui features2d calib3d ml objdetect video contrib legacy photo gpu java ocl python stitching superres ts videostab
    Disabled:                    world
    Disabled by dependency:      -
    Unavailable:                 androidcamera dynamicuda

  GUI: 
    QT:                          NO
    GTK+ 2.x:                    YES (ver 2.24.22)
    GThread :                    YES (ver 2.39.90)
    GtkGlExt:                    YES (ver 1.2.0)
    OpenGL support:              YES (/usr/lib/x86_64-linux-gnu/libGLU.so /usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libSM.so /usr/lib/x86_64-linux-gnu/libICE.so /usr/lib/x86_64-linux-gnu/libX11.so /usr/lib/x86_64-linux-gnu/libXext.so)

  Media I/O: 
    ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.8)
    JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver )
    PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.2.50)
    TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 - 4.0.3)
    JPEG 2000:                   /usr/lib/x86_64-linux-gnu/libjasper.so (ver 1.900.1)
    OpenEXR:                     /usr/lib/x86_64-linux-gnu/libImath.so /usr/lib/x86_64-linux-gnu/libIlmImf.so /usr/lib/x86_64-linux-gnu/libIex.so /usr/lib/x86_64-linux-gnu/libHalf.so /usr/lib/x86_64-linux-gnu/libIlmThread.so (ver 1.6.1)

  Video I/O:
    DC1394 1.x:                  NO
    DC1394 2.x:                  YES (ver 2.2.1)
    FFMPEG:                      YES
      codec:                     YES (ver 54.35.0)
      format:                    YES (ver 54.20.3)
      util:                      YES (ver 52.3.0)
      swscale:                   YES (ver 2.1.1)
      gentoo-style:              YES
    GStreamer:                   NO
    OpenNI:                      NO
    OpenNI PrimeSensor Modules:  NO
    PvAPI:                       NO
    GigEVisionSDK:               NO
    UniCap:                      NO
    UniCap ucil:                 NO
    V4L/V4L2:                    Using libv4l (ver 1.0.1)
    XIMEA:                       NO
    Xine:                        NO

  Other third-party libraries:
    Use IPP:                     NO
    Use Eigen:                   YES (ver 3.2.0)
    Use TBB:                     YES (ver 4.2 interface 7000)
    Use OpenMP:                  NO
    Use GCD                      NO
    Use Concurrency              NO
    Use C=:                      NO
    Use Cuda:                    NO
    Use OpenCL:                  YES

  OpenCL:
    Version:                     dynamic
    Use AMD FFT:                 NO
    Use AMD BLAS:                NO

  Python:
    Interpreter:                 /usr/bin/python2 (ver 2.7.6)
    Libraries:                   /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.6)
    numpy:                       /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.8.0.dev-95f7a46)
    packages path:               lib/python2.7/dist-packages

  Java:
    ant:                         /usr/bin/ant (ver 1.9.3)
    JNI:                         /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include
    Java tests:                  NO

  Documentation:
    Build Documentation:         YES
    Sphinx:                      /usr/bin/sphinx-build (ver 1.2.1)
    PdfLaTeX compiler:           /usr/bin/pdflatex

  Tests and samples:
    Tests:                       NO
    Performance tests:           YES
    C/C++ Examples:              YES

  Install path:                  /usr

  cvconfig.h is in:              /build/buildd/opencv-2.4.8+dfsg1/obj-x86_64-linux-gnu
-----------------------------------------------------------------


==15342== 
==15342== HEAP SUMMARY:
==15342==     in use at exit: 4,616 bytes in 9 blocks
==15342==   total heap usage: 52 allocs, 43 frees, 17,572 bytes allocated
==15342== 
==15342== 3,096 bytes in 3 blocks are possibly lost in loss record 7 of 7
==15342==    at 0x4C2B800: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15342==    by 0x68C923B: ??? (in /usr/lib/libtbb.so.2)
==15342==    by 0x68C95BD: ??? (in /usr/lib/libtbb.so.2)
==15342==    by 0x68C7B02: ??? (in /usr/lib/libtbb.so.2)
==15342==    by 0x68C7359: ??? (in /usr/lib/libtbb.so.2)
==15342==    by 0x68C5800: tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const (in /usr/lib/libtbb.so.2)
==15342==    by 0x4FD9489: cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double) (in /usr/lib/x86_64-linux-gnu/libopencv_core.so.2.4.8)
==15342==    by 0x534E89B: void cv::CvtColorLoop<cv::RGB2Gray<unsigned char> >(cv::Mat const&, cv::Mat&, cv::RGB2Gray<unsigned char> const&) (in /usr/lib/x86_64-linux-gnu/libopencv_imgproc.so.2.4.8)
==15342==    by 0x535BDDD: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib/x86_64-linux-gnu/libopencv_imgproc.so.2.4.8)
==15342==    by 0x400E78: main (in /home/gfolego/projects/test/test)
==15342== 
==15342== LEAK SUMMARY:
==15342==    definitely lost: 0 bytes in 0 blocks
==15342==    indirectly lost: 0 bytes in 0 blocks
==15342==      possibly lost: 3,096 bytes in 3 blocks
==15342==    still reachable: 1,520 bytes in 6 blocks
==15342==         suppressed: 0 bytes in 0 blocks
==15342== Reachable blocks (those to which a pointer was found) are not shown.
==15342== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==15342== 
==15342== For counts of detected and suppressed errors, rerun with: -v
==15342== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

Is this the expected output? What am I missing in order to fix this memory leak?

Thanks and best regards!

====================

[UPDATE 2015-07-20]

After some more tests, I found out that the memory leak occurs when OpenCV is built with TBB support. These are the results using OpenCV 2.4.11.

Building OpenCV:

$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=<opencv_install_path> ..
$ make -j9
$ make -j9 install

Building sample:

$ g++ -Wall -Wextra -Werror -Weffc++ -ansi -pedantic -O2 test.cpp -o test -I<opencv_install_path>/include/opencv <opencv_install_path>/lib/libopencv_core.so <opencv_install_path>/lib/libopencv_imgproc.so

And the output:

$ LD_LIBRARY_PATH=<opencv_install_path>/lib/:$LD_LIBRARY_PATH valgrind --leak-check=full ./test
==18997== Memcheck, a memory error detector
==18997== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==18997== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright info
==18997== Command: ./test
==18997== 

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

  Platform:
    Host:                        Linux 3.16.0-34-generic x86_64
    CMake:                       2.8.12.2
    CMake generator:             Unix Makefiles
    CMake build tool:            /usr/bin/make
    Configuration:               RELEASE

  C/C++:
    Built as dynamic libs?:      YES
    C++ Compiler:                /usr/bin/c++  (ver 4.8.4)
    C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -O3 -DNDEBUG  -DNDEBUG
    C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG
    C Compiler:                  /usr/bin/cc
    C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -O3 -DNDEBUG  -DNDEBUG
    C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG
    Linker flags (Release):      
    Linker flags (Debug):        
    Precompiled headers:         YES

  OpenCV modules:
    To be built:                 core flann imgproc highgui features2d calib3d ml video legacy objdetect photo gpu ocl nonfree contrib java python stitching superres ts videostab
    Disabled:                    world
    Disabled by dependency:      -
    Unavailable:                 androidcamera dynamicuda viz

  GUI: 
    QT:                          NO
    GTK+ 2.x:                    YES (ver 2.24.23)
    GThread :                    YES (ver 2.40.2)
    GtkGlExt:                    NO
    OpenGL support:              NO
    VTK support:                 NO

  Media I/O: 
    ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.8)
    JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver )
    PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.2.50)
    TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 - 4.0.3)
    JPEG 2000:                   /usr/lib/x86_64-linux-gnu/libjasper.so (ver 1.900.1)
    OpenEXR:                     /usr/lib/x86_64-linux-gnu/libImath.so /usr/lib/x86_64-linux-gnu/libIlmImf.so /usr/lib/x86_64-linux-gnu/libIex.so /usr/lib/x86_64-linux-gnu/libHalf.so /usr/lib/x86_64-linux-gnu/libIlmThread.so (ver 1.6.1)

  Video I/O:
    DC1394 1.x:                  NO
    DC1394 2.x:                  YES (ver 2.2.1)
    FFMPEG:                      YES
      codec:                     YES (ver 54.35.0)
      format:                    YES (ver 54.20.4)
      util:                      YES (ver 52.3.0)
      swscale:                   YES (ver 2.1.1)
      gentoo-style:              YES
    GStreamer:                   
      base:                      YES (ver 0.10.36)
      video:                     YES (ver 0.10.36)
      app:                       YES (ver 0.10.36)
      riff:                      YES (ver 0.10.36)
      pbutils:                   YES (ver 0.10.36)
    OpenNI:                      NO
    OpenNI PrimeSensor Modules:  NO
    PvAPI:                       NO
    GigEVisionSDK:               NO
    UniCap:                      NO
    UniCap ucil:                 NO
    V4L/V4L2:                    Using libv4l1 (ver 1.0.1) / libv4l2 (ver 1.0.1)
    XIMEA:                       NO
    Xine:                        NO

  Other third-party libraries:
    Use IPP:                     NO
    Use Eigen:                   YES (ver 3.2.0)
    Use TBB:                     NO
    Use OpenMP:                  NO
    Use GCD                      NO
    Use Concurrency              NO
    Use C=:                      NO
    Use Cuda:                    NO
    Use OpenCL:                  YES

  OpenCL:
    Version:                     dynamic
    Include path:                /home/gfolego/packages/opencv-2.4.11/3rdparty/include/opencl/1.2
    Use AMD FFT:                 NO
    Use AMD BLAS:                NO

  Python:
    Interpreter:                 /usr/bin/python2 (ver 2.7.6)
    Libraries:                   /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.6)
    numpy:                       /usr/local/lib/python2.7/dist-packages/numpy/core/include (ver 1.9.2)
    packages path:               lib/python2.7/dist-packages

  Java:
    ant:                         /usr/bin/ant (ver 1.9.3)
    JNI:                         /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include
    Java tests:                  YES

  Documentation:
    Build Documentation:         NO
    Sphinx:                      NO
    PdfLaTeX compiler:           /usr/bin/pdflatex
    Doxygen:                     YES (/usr/bin/doxygen)

  Tests and samples:
    Tests:                       YES
    Performance tests:           YES
    C/C++ Examples:              NO

  Install path:                  /home/gfolego/packages/opencv-2.4.11/release/installed

  cvconfig.h is in:              /home/gfolego/packages/opencv-2.4.11/release
-----------------------------------------------------------------


==18997== 
==18997== HEAP SUMMARY:
==18997==     in use at exit: 0 bytes in 0 blocks
==18997==   total heap usage: 27 allocs, 27 frees, 10,961 bytes allocated
==18997== 
==18997== All heap blocks were freed -- no leaks are possible
==18997== 
==18997== For counts of detected and suppressed errors, rerun with: -v
==18997== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Now, building OpenCV with TBB support:

$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=<opencv_install_path> -D WITH_TBB=ON ..
$ make -j9
$ make -j9 install

Building the sample with the new library:

$ g++ -Wall -Wextra -Werror -Weffc++ -ansi -pedantic -O2 test.cpp -o test -I/home/gfolego/packages/opencv-2.4.11/release/installed/include/opencv /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_core.so /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so

And the new output:

$ LD_LIBRARY_PATH=/home/gfolego/packages/opencv-2.4.11/release/installed/lib/:$LD_LIBRARY_PATH valgrind --leak-check=full ./test 
==31226== Memcheck, a memory error detector
==31226== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==31226== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright info
==31226== Command: ./test
==31226== 

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

  Platform:
    Host:                        Linux 3.16.0-34-generic x86_64
    CMake:                       2.8.12.2
    CMake generator:             Unix Makefiles
    CMake build tool:            /usr/bin/make
    Configuration:               RELEASE

  C/C++:
    Built as dynamic libs?:      YES
    C++ Compiler:                /usr/bin/c++  (ver 4.8.4)
    C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -O3 -DNDEBUG  -DNDEBUG
    C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG
    C Compiler:                  /usr/bin/cc
    C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -O3 -DNDEBUG  -DNDEBUG
    C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG
    Linker flags (Release):      
    Linker flags (Debug):        
    Precompiled headers:         YES

  OpenCV modules:
    To be built:                 core flann imgproc highgui features2d calib3d ml video legacy objdetect photo gpu ocl nonfree contrib java python stitching superres ts videostab
    Disabled:                    world
    Disabled by dependency:      -
    Unavailable:                 androidcamera dynamicuda viz

  GUI: 
    QT:                          NO
    GTK+ 2.x:                    YES (ver 2.24.23)
    GThread :                    YES (ver 2.40.2)
    GtkGlExt:                    NO
    OpenGL support:              NO
    VTK support:                 NO

  Media I/O: 
    ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.8)
    JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver )
    PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.2.50)
    TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 - 4.0.3)
    JPEG 2000:                   /usr/lib/x86_64-linux-gnu/libjasper.so (ver 1.900.1)
    OpenEXR:                     /usr/lib/x86_64-linux-gnu/libImath.so /usr/lib/x86_64-linux-gnu/libIlmImf.so /usr/lib/x86_64-linux-gnu/libIex.so /usr/lib/x86_64-linux-gnu/libHalf.so /usr/lib/x86_64-linux-gnu/libIlmThread.so (ver 1.6.1)

  Video I/O:
    DC1394 1.x:                  NO
    DC1394 2.x:                  YES (ver 2.2.1)
    FFMPEG:                      YES
      codec:                     YES (ver 54.35.0)
      format:                    YES (ver 54.20.4)
      util:                      YES (ver 52.3.0)
      swscale:                   YES (ver 2.1.1)
      gentoo-style:              YES
    GStreamer:                   
      base:                      YES (ver 0.10.36)
      video:                     YES (ver 0.10.36)
      app:                       YES (ver 0.10.36)
      riff:                      YES (ver 0.10.36)
      pbutils:                   YES (ver 0.10.36)
    OpenNI:                      NO
    OpenNI PrimeSensor Modules:  NO
    PvAPI:                       NO
    GigEVisionSDK:               NO
    UniCap:                      NO
    UniCap ucil:                 NO
    V4L/V4L2:                    Using libv4l1 (ver 1.0.1) / libv4l2 (ver 1.0.1)
    XIMEA:                       NO
    Xine:                        NO

  Other third-party libraries:
    Use IPP:                     NO
    Use Eigen:                   YES (ver 3.2.0)
    Use TBB:                     YES (ver 4.2 interface 7000)
    Use OpenMP:                  NO
    Use GCD                      NO
    Use Concurrency              NO
    Use C=:                      NO
    Use Cuda:                    NO
    Use OpenCL:                  YES

  OpenCL:
    Version:                     dynamic
    Include path:                /home/gfolego/packages/opencv-2.4.11/3rdparty/include/opencl/1.2
    Use AMD FFT:                 NO
    Use AMD BLAS:                NO

  Python:
    Interpreter:                 /usr/bin/python2 (ver 2.7.6)
    Libraries:                   /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.6)
    numpy:                       /usr/local/lib/python2.7/dist-packages/numpy/core/include (ver 1.9.2)
    packages path:               lib/python2.7/dist-packages

  Java:
    ant:                         /usr/bin/ant (ver 1.9.3)
    JNI:                         /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include
    Java tests:                  YES

  Documentation:
    Build Documentation:         NO
    Sphinx:                      NO
    PdfLaTeX compiler:           /usr/bin/pdflatex
    Doxygen:                     YES (/usr/bin/doxygen)

  Tests and samples:
    Tests:                       YES
    Performance tests:           YES
    C/C++ Examples:              NO

  Install path:                  /home/gfolego/packages/opencv-2.4.11/release/installed

  cvconfig.h is in:              /home/gfolego/packages/opencv-2.4.11/release
-----------------------------------------------------------------


==31226== 
==31226== HEAP SUMMARY:
==31226==     in use at exit: 24,160 bytes in 60 blocks
==31226==   total heap usage: 92 allocs, 32 frees, 36,209 bytes allocated
==31226== 
==31226== 192 bytes in 1 blocks are possibly lost in loss record 1 of 12
==31226==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==31226==    by 0x671195B: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6711B70: tbb::internal::NFS_Allocate(unsigned long, unsigned long, void*) (in /usr/lib/libtbb.so.2)
==31226==    by 0x6716339: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719175: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x671987D: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719994: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719AE4: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719359: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6717800: tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const (in /usr/lib/libtbb.so.2)
==31226==    by 0x4F77CF9: cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_core.so.2.4.11)
==31226==    by 0x54A6B94: void cv::CvtColorLoop<cv::RGB2Gray<unsigned char> >(cv::Mat const&, cv::Mat&, cv::RGB2Gray<unsigned char> const&) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226== 
==31226== 384 bytes in 1 blocks are possibly lost in loss record 2 of 12
==31226==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==31226==    by 0x671195B: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6711B70: tbb::internal::NFS_Allocate(unsigned long, unsigned long, void*) (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719971: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719AE4: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719359: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6717800: tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const (in /usr/lib/libtbb.so.2)
==31226==    by 0x4F77CF9: cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_core.so.2.4.11)
==31226==    by 0x54A6B94: void cv::CvtColorLoop<cv::RGB2Gray<unsigned char> >(cv::Mat const&, cv::Mat&, cv::RGB2Gray<unsigned char> const&) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x54B846D: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x400E78: main (in /home/gfolego/projects/test/test)
==31226== 
==31226== 384 bytes in 1 blocks are possibly lost in loss record 3 of 12
==31226==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==31226==    by 0x671195B: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6711B70: tbb::internal::NFS_Allocate(unsigned long, unsigned long, void*) (in /usr/lib/libtbb.so.2)
==31226==    by 0x671B3F8: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x671B5BD: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719B02: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719359: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6717800: tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const (in /usr/lib/libtbb.so.2)
==31226==    by 0x4F77CF9: cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_core.so.2.4.11)
==31226==    by 0x54A6B94: void cv::CvtColorLoop<cv::RGB2Gray<unsigned char> >(cv::Mat const&, cv::Mat&, cv::RGB2Gray<unsigned char> const&) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x54B846D: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x400E78: main (in /home/gfolego/projects/test/test)
==31226== 
==31226== 384 bytes in 1 blocks are possibly lost in loss record 4 of 12
==31226==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==31226==    by 0x671195B: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6711B70: tbb::internal::NFS_Allocate(unsigned long, unsigned long, void*) (in /usr/lib/libtbb.so.2)
==31226==    by 0x671BD97: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x671BEF4: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x671D720: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x671C811: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719361: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6717800: tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const (in /usr/lib/libtbb.so.2)
==31226==    by 0x4F77CF9: cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_core.so.2.4.11)
==31226==    by 0x54A6B94: void cv::CvtColorLoop<cv::RGB2Gray<unsigned char> >(cv::Mat const&, cv::Mat&, cv::RGB2Gray<unsigned char> const&) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x54B846D: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226== 
==31226== 384 bytes in 1 blocks are possibly lost in loss record 5 of 12
==31226==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==31226==    by 0x671195B: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6711B70: tbb::internal::NFS_Allocate(unsigned long, unsigned long, void*) (in /usr/lib/libtbb.so.2)
==31226==    by 0x671BD97: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6717786: tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const (in /usr/lib/libtbb.so.2)
==31226==    by 0x4F77CF9: cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_core.so.2.4.11)
==31226==    by 0x54A6B94: void cv::CvtColorLoop<cv::RGB2Gray<unsigned char> >(cv::Mat const&, cv::Mat&, cv::RGB2Gray<unsigned char> const&) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x54B846D: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x400E78: main (in /home/gfolego/projects/test/test)
==31226== 
==31226== 384 bytes in 1 blocks are possibly lost in loss record 6 of 12
==31226==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==31226==    by 0x671195B: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6711B70: tbb::internal::NFS_Allocate(unsigned long, unsigned long, void*) (in /usr/lib/libtbb.so.2)
==31226==    by 0x671BD97: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x671CF12: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x4F77D50: cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_core.so.2.4.11)
==31226==    by 0x54A6B94: void cv::CvtColorLoop<cv::RGB2Gray<unsigned char> >(cv::Mat const&, cv::Mat&, cv::RGB2Gray<unsigned char> const&) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x54B846D: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x400E78: main (in /home/gfolego/projects/test/test)
==31226== 
==31226== 520 bytes in 1 blocks are possibly lost in loss record 7 of 12
==31226==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==31226==    by 0x671195B: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6711B70: tbb::internal::NFS_Allocate(unsigned long, unsigned long, void*) (in /usr/lib/libtbb.so.2)
==31226==    by 0x671D70A: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x671C811: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719361: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6717800: tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const (in /usr/lib/libtbb.so.2)
==31226==    by 0x4F77CF9: cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_core.so.2.4.11)
==31226==    by 0x54A6B94: void cv::CvtColorLoop<cv::RGB2Gray<unsigned char> >(cv::Mat const&, cv::Mat&, cv::RGB2Gray<unsigned char> const&) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x54B846D: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x400E78: main (in /home/gfolego/projects/test/test)
==31226== 
==31226== 1,024 bytes in 1 blocks are possibly lost in loss record 8 of 12
==31226==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==31226==    by 0x671195B: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6711B70: tbb::internal::NFS_Allocate(unsigned long, unsigned long, void*) (in /usr/lib/libtbb.so.2)
==31226==    by 0x6715CC1: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x671634C: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719175: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x671987D: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719994: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719AE4: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719359: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6717800: tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const (in /usr/lib/libtbb.so.2)
==31226==    by 0x4F77CF9: cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_core.so.2.4.11)
==31226== 
==31226== 1,536 bytes in 24 blocks are possibly lost in loss record 9 of 12
==31226==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==31226==    by 0x6711BC9: tbb::internal::allocate_via_handler_v3(unsigned long) (in /usr/lib/libtbb.so.2)
==31226==    by 0x671B2CB: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x671B5BD: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719B02: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719359: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6717800: tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const (in /usr/lib/libtbb.so.2)
==31226==    by 0x4F77CF9: cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_core.so.2.4.11)
==31226==    by 0x54A6B94: void cv::CvtColorLoop<cv::RGB2Gray<unsigned char> >(cv::Mat const&, cv::Mat&, cv::RGB2Gray<unsigned char> const&) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x54B846D: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x400E78: main (in /home/gfolego/projects/test/test)
==31226== 
==31226== 3,096 bytes in 3 blocks are possibly lost in loss record 10 of 12
==31226==    at 0x4C2B800: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==31226==    by 0x671B23B: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x671B5BD: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719B02: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719359: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6717800: tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const (in /usr/lib/libtbb.so.2)
==31226==    by 0x4F77CF9: cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_core.so.2.4.11)
==31226==    by 0x54A6B94: void cv::CvtColorLoop<cv::RGB2Gray<unsigned char> >(cv::Mat const&, cv::Mat&, cv::RGB2Gray<unsigned char> const&) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x54B846D: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x400E78: main (in /home/gfolego/projects/test/test)
==31226== 
==31226== 3,584 bytes in 1 blocks are possibly lost in loss record 11 of 12
==31226==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==31226==    by 0x671195B: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6711B70: tbb::internal::NFS_Allocate(unsigned long, unsigned long, void*) (in /usr/lib/libtbb.so.2)
==31226==    by 0x671B594: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719B02: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719359: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6717800: tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const (in /usr/lib/libtbb.so.2)
==31226==    by 0x4F77CF9: cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_core.so.2.4.11)
==31226==    by 0x54A6B94: void cv::CvtColorLoop<cv::RGB2Gray<unsigned char> >(cv::Mat const&, cv::Mat&, cv::RGB2Gray<unsigned char> const&) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x54B846D: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x400E78: main (in /home/gfolego/projects/test/test)
==31226== 
==31226== 12,288 bytes in 24 blocks are possibly lost in loss record 12 of 12
==31226==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==31226==    by 0x6711BC9: tbb::internal::allocate_via_handler_v3(unsigned long) (in /usr/lib/libtbb.so.2)
==31226==    by 0x671B2EC: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x671B5BD: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719B02: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719359: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6717800: tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const (in /usr/lib/libtbb.so.2)
==31226==    by 0x4F77CF9: cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_core.so.2.4.11)
==31226==    by 0x54A6B94: void cv::CvtColorLoop<cv::RGB2Gray<unsigned char> >(cv::Mat const&, cv::Mat&, cv::RGB2Gray<unsigned char> const&) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x54B846D: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x400E78: main (in /home/gfolego/projects/test/test)
==31226== 
==31226== LEAK SUMMARY:
==31226==    definitely lost: 0 bytes in 0 blocks
==31226==    indirectly lost: 0 bytes in 0 blocks
==31226==      possibly lost: 24,160 bytes in 60 blocks
==31226==    still reachable: 0 bytes in 0 blocks
==31226==         suppressed: 0 bytes in 0 blocks
==31226== 
==31226== For counts of detected and suppressed errors, rerun with: -v
==31226== ERROR SUMMARY: 12 errors from 12 contexts (suppressed: 0 from 0)

Possible memory leak in cvtColor with TBB support

Dear all,

I'm running some tests with cvtColor and valgrind reports a memory leak.

Some information about the environment:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.2 LTS
Release:    14.04
Codename:   trusty

$ uname --all
Linux <hidden> 3.16.0-34-generic #47~14.04.1-Ubuntu SMP Fri Apr 10 17:49:16 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

$ pkg-config --modversion opencv
2.4.8

$ g++ --version
g++ (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ valgrind --version
valgrind-3.10.0.SVN

This is a short standalone sample:

$ cat test.cpp 
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>

int main()
{
    std::cout << cv::getBuildInformation() << std::endl;

    cv::Mat src = cv::Mat::zeros(5, 5, CV_8UC3);
    cv::Mat dst;

    cv::cvtColor( src, dst, CV_BGR2GRAY );
}


$ g++ -Wall -Wextra -Werror -Weffc++ -ansi -pedantic -O2 test.cpp -o test  $(pkg-config --cflags --libs opencv) 
<nothing printed on screen>

And the output from valgrind:

$ valgrind --leak-check=full ./test 
==15342== Memcheck, a memory error detector
==15342== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==15342== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright info
==15342== Command: ./test
==15342== 

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

  Platform:
    Host:                        Linux 3.2.0-58-generic x86_64
    CMake:                       2.8.12.2
    CMake generator:             Unix Makefiles
    CMake build tool:            /usr/bin/make
    Configuration:               Release

  C/C++:
    Built as dynamic libs?:      YES
    C++ Compiler:                /usr/bin/x86_64-linux-gnu-g++  (ver 4.8.2)
    C++ flags (Release):         -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2    -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -ffunction-sections -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security  -DNDEBUG
    C++ flags (Debug):           -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2    -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG
    C Compiler:                  /usr/bin/x86_64-linux-gnu-gcc
    C flags (Release):           -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2    -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -ffunction-sections -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security  -DNDEBUG
    C flags (Debug):             -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2    -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG
    Linker flags (Release):      -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now
    Linker flags (Debug):        -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now
    Precompiled headers:         YES

  OpenCV modules:
    To be built:                 core flann imgproc highgui features2d calib3d ml objdetect video contrib legacy photo gpu java ocl python stitching superres ts videostab
    Disabled:                    world
    Disabled by dependency:      -
    Unavailable:                 androidcamera dynamicuda

  GUI: 
    QT:                          NO
    GTK+ 2.x:                    YES (ver 2.24.22)
    GThread :                    YES (ver 2.39.90)
    GtkGlExt:                    YES (ver 1.2.0)
    OpenGL support:              YES (/usr/lib/x86_64-linux-gnu/libGLU.so /usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libSM.so /usr/lib/x86_64-linux-gnu/libICE.so /usr/lib/x86_64-linux-gnu/libX11.so /usr/lib/x86_64-linux-gnu/libXext.so)

  Media I/O: 
    ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.8)
    JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver )
    PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.2.50)
    TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 - 4.0.3)
    JPEG 2000:                   /usr/lib/x86_64-linux-gnu/libjasper.so (ver 1.900.1)
    OpenEXR:                     /usr/lib/x86_64-linux-gnu/libImath.so /usr/lib/x86_64-linux-gnu/libIlmImf.so /usr/lib/x86_64-linux-gnu/libIex.so /usr/lib/x86_64-linux-gnu/libHalf.so /usr/lib/x86_64-linux-gnu/libIlmThread.so (ver 1.6.1)

  Video I/O:
    DC1394 1.x:                  NO
    DC1394 2.x:                  YES (ver 2.2.1)
    FFMPEG:                      YES
      codec:                     YES (ver 54.35.0)
      format:                    YES (ver 54.20.3)
      util:                      YES (ver 52.3.0)
      swscale:                   YES (ver 2.1.1)
      gentoo-style:              YES
    GStreamer:                   NO
    OpenNI:                      NO
    OpenNI PrimeSensor Modules:  NO
    PvAPI:                       NO
    GigEVisionSDK:               NO
    UniCap:                      NO
    UniCap ucil:                 NO
    V4L/V4L2:                    Using libv4l (ver 1.0.1)
    XIMEA:                       NO
    Xine:                        NO

  Other third-party libraries:
    Use IPP:                     NO
    Use Eigen:                   YES (ver 3.2.0)
    Use TBB:                     YES (ver 4.2 interface 7000)
    Use OpenMP:                  NO
    Use GCD                      NO
    Use Concurrency              NO
    Use C=:                      NO
    Use Cuda:                    NO
    Use OpenCL:                  YES

  OpenCL:
    Version:                     dynamic
    Use AMD FFT:                 NO
    Use AMD BLAS:                NO

  Python:
    Interpreter:                 /usr/bin/python2 (ver 2.7.6)
    Libraries:                   /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.6)
    numpy:                       /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.8.0.dev-95f7a46)
    packages path:               lib/python2.7/dist-packages

  Java:
    ant:                         /usr/bin/ant (ver 1.9.3)
    JNI:                         /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include
    Java tests:                  NO

  Documentation:
    Build Documentation:         YES
    Sphinx:                      /usr/bin/sphinx-build (ver 1.2.1)
    PdfLaTeX compiler:           /usr/bin/pdflatex

  Tests and samples:
    Tests:                       NO
    Performance tests:           YES
    C/C++ Examples:              YES

  Install path:                  /usr

  cvconfig.h is in:              /build/buildd/opencv-2.4.8+dfsg1/obj-x86_64-linux-gnu
-----------------------------------------------------------------


==15342== 
==15342== HEAP SUMMARY:
==15342==     in use at exit: 4,616 bytes in 9 blocks
==15342==   total heap usage: 52 allocs, 43 frees, 17,572 bytes allocated
==15342== 
==15342== 3,096 bytes in 3 blocks are possibly lost in loss record 7 of 7
==15342==    at 0x4C2B800: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15342==    by 0x68C923B: ??? (in /usr/lib/libtbb.so.2)
==15342==    by 0x68C95BD: ??? (in /usr/lib/libtbb.so.2)
==15342==    by 0x68C7B02: ??? (in /usr/lib/libtbb.so.2)
==15342==    by 0x68C7359: ??? (in /usr/lib/libtbb.so.2)
==15342==    by 0x68C5800: tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const (in /usr/lib/libtbb.so.2)
==15342==    by 0x4FD9489: cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double) (in /usr/lib/x86_64-linux-gnu/libopencv_core.so.2.4.8)
==15342==    by 0x534E89B: void cv::CvtColorLoop<cv::RGB2Gray<unsigned char> >(cv::Mat const&, cv::Mat&, cv::RGB2Gray<unsigned char> const&) (in /usr/lib/x86_64-linux-gnu/libopencv_imgproc.so.2.4.8)
==15342==    by 0x535BDDD: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib/x86_64-linux-gnu/libopencv_imgproc.so.2.4.8)
==15342==    by 0x400E78: main (in /home/gfolego/projects/test/test)
==15342== 
==15342== LEAK SUMMARY:
==15342==    definitely lost: 0 bytes in 0 blocks
==15342==    indirectly lost: 0 bytes in 0 blocks
==15342==      possibly lost: 3,096 bytes in 3 blocks
==15342==    still reachable: 1,520 bytes in 6 blocks
==15342==         suppressed: 0 bytes in 0 blocks
==15342== Reachable blocks (those to which a pointer was found) are not shown.
==15342== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==15342== 
==15342== For counts of detected and suppressed errors, rerun with: -v
==15342== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

Is this the expected output? What am I missing in order to fix this memory leak?

Thanks and best regards!

====================

[UPDATE 2015-07-20]

After some more tests, I found out that the memory leak occurs when OpenCV is built with TBB support. These are the results using OpenCV 2.4.11.

Building OpenCV:

$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=<opencv_install_path> ..
$ make -j9
$ make -j9 install

Building sample:

$ g++ -Wall -Wextra -Werror -Weffc++ -ansi -pedantic -O2 test.cpp -o test -I<opencv_install_path>/include/opencv <opencv_install_path>/lib/libopencv_core.so <opencv_install_path>/lib/libopencv_imgproc.so

And the output:

$ LD_LIBRARY_PATH=<opencv_install_path>/lib/:$LD_LIBRARY_PATH valgrind --leak-check=full ./test
==18997== Memcheck, a memory error detector
==18997== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==18997== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright info
==18997== Command: ./test
==18997== 

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

  Platform:
    Host:                        Linux 3.16.0-34-generic x86_64
    CMake:                       2.8.12.2
    CMake generator:             Unix Makefiles
    CMake build tool:            /usr/bin/make
    Configuration:               RELEASE

  C/C++:
    Built as dynamic libs?:      YES
    C++ Compiler:                /usr/bin/c++  (ver 4.8.4)
    C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -O3 -DNDEBUG  -DNDEBUG
    C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG
    C Compiler:                  /usr/bin/cc
    C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -O3 -DNDEBUG  -DNDEBUG
    C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG
    Linker flags (Release):      
    Linker flags (Debug):        
    Precompiled headers:         YES

  OpenCV modules:
    To be built:                 core flann imgproc highgui features2d calib3d ml video legacy objdetect photo gpu ocl nonfree contrib java python stitching superres ts videostab
    Disabled:                    world
    Disabled by dependency:      -
    Unavailable:                 androidcamera dynamicuda viz

  GUI: 
    QT:                          NO
    GTK+ 2.x:                    YES (ver 2.24.23)
    GThread :                    YES (ver 2.40.2)
    GtkGlExt:                    NO
    OpenGL support:              NO
    VTK support:                 NO

  Media I/O: 
    ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.8)
    JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver )
    PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.2.50)
    TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 - 4.0.3)
    JPEG 2000:                   /usr/lib/x86_64-linux-gnu/libjasper.so (ver 1.900.1)
    OpenEXR:                     /usr/lib/x86_64-linux-gnu/libImath.so /usr/lib/x86_64-linux-gnu/libIlmImf.so /usr/lib/x86_64-linux-gnu/libIex.so /usr/lib/x86_64-linux-gnu/libHalf.so /usr/lib/x86_64-linux-gnu/libIlmThread.so (ver 1.6.1)

  Video I/O:
    DC1394 1.x:                  NO
    DC1394 2.x:                  YES (ver 2.2.1)
    FFMPEG:                      YES
      codec:                     YES (ver 54.35.0)
      format:                    YES (ver 54.20.4)
      util:                      YES (ver 52.3.0)
      swscale:                   YES (ver 2.1.1)
      gentoo-style:              YES
    GStreamer:                   
      base:                      YES (ver 0.10.36)
      video:                     YES (ver 0.10.36)
      app:                       YES (ver 0.10.36)
      riff:                      YES (ver 0.10.36)
      pbutils:                   YES (ver 0.10.36)
    OpenNI:                      NO
    OpenNI PrimeSensor Modules:  NO
    PvAPI:                       NO
    GigEVisionSDK:               NO
    UniCap:                      NO
    UniCap ucil:                 NO
    V4L/V4L2:                    Using libv4l1 (ver 1.0.1) / libv4l2 (ver 1.0.1)
    XIMEA:                       NO
    Xine:                        NO

  Other third-party libraries:
    Use IPP:                     NO
    Use Eigen:                   YES (ver 3.2.0)
    Use TBB:                     NO
    Use OpenMP:                  NO
    Use GCD                      NO
    Use Concurrency              NO
    Use C=:                      NO
    Use Cuda:                    NO
    Use OpenCL:                  YES

  OpenCL:
    Version:                     dynamic
    Include path:                /home/gfolego/packages/opencv-2.4.11/3rdparty/include/opencl/1.2
    Use AMD FFT:                 NO
    Use AMD BLAS:                NO

  Python:
    Interpreter:                 /usr/bin/python2 (ver 2.7.6)
    Libraries:                   /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.6)
    numpy:                       /usr/local/lib/python2.7/dist-packages/numpy/core/include (ver 1.9.2)
    packages path:               lib/python2.7/dist-packages

  Java:
    ant:                         /usr/bin/ant (ver 1.9.3)
    JNI:                         /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include
    Java tests:                  YES

  Documentation:
    Build Documentation:         NO
    Sphinx:                      NO
    PdfLaTeX compiler:           /usr/bin/pdflatex
    Doxygen:                     YES (/usr/bin/doxygen)

  Tests and samples:
    Tests:                       YES
    Performance tests:           YES
    C/C++ Examples:              NO

  Install path:                  /home/gfolego/packages/opencv-2.4.11/release/installed

  cvconfig.h is in:              /home/gfolego/packages/opencv-2.4.11/release
-----------------------------------------------------------------


==18997== 
==18997== HEAP SUMMARY:
==18997==     in use at exit: 0 bytes in 0 blocks
==18997==   total heap usage: 27 allocs, 27 frees, 10,961 bytes allocated
==18997== 
==18997== All heap blocks were freed -- no leaks are possible
==18997== 
==18997== For counts of detected and suppressed errors, rerun with: -v
==18997== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Now, building OpenCV with TBB support:

$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=<opencv_install_path> -D WITH_TBB=ON ..
$ make -j9
$ make -j9 install

Building the sample with the new library:

$ g++ -Wall -Wextra -Werror -Weffc++ -ansi -pedantic -O2 test.cpp -o test -I/home/gfolego/packages/opencv-2.4.11/release/installed/include/opencv /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_core.so /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so
-I<opencv_install_path>/include/opencv <opencv_install_path>/lib/libopencv_core.so <opencv_install_path>/lib/libopencv_imgproc.so

And the new output:

$ LD_LIBRARY_PATH=/home/gfolego/packages/opencv-2.4.11/release/installed/lib/:$LD_LIBRARY_PATH valgrind --leak-check=full ./test 
==31226== Memcheck, a memory error detector
==31226== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==31226== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright info
==31226== Command: ./test
==31226== 

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

  Platform:
    Host:                        Linux 3.16.0-34-generic x86_64
    CMake:                       2.8.12.2
    CMake generator:             Unix Makefiles
    CMake build tool:            /usr/bin/make
    Configuration:               RELEASE

  C/C++:
    Built as dynamic libs?:      YES
    C++ Compiler:                /usr/bin/c++  (ver 4.8.4)
    C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -O3 -DNDEBUG  -DNDEBUG
    C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG
    C Compiler:                  /usr/bin/cc
    C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -O3 -DNDEBUG  -DNDEBUG
    C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG
    Linker flags (Release):      
    Linker flags (Debug):        
    Precompiled headers:         YES

  OpenCV modules:
    To be built:                 core flann imgproc highgui features2d calib3d ml video legacy objdetect photo gpu ocl nonfree contrib java python stitching superres ts videostab
    Disabled:                    world
    Disabled by dependency:      -
    Unavailable:                 androidcamera dynamicuda viz

  GUI: 
    QT:                          NO
    GTK+ 2.x:                    YES (ver 2.24.23)
    GThread :                    YES (ver 2.40.2)
    GtkGlExt:                    NO
    OpenGL support:              NO
    VTK support:                 NO

  Media I/O: 
    ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.8)
    JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver )
    PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.2.50)
    TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 - 4.0.3)
    JPEG 2000:                   /usr/lib/x86_64-linux-gnu/libjasper.so (ver 1.900.1)
    OpenEXR:                     /usr/lib/x86_64-linux-gnu/libImath.so /usr/lib/x86_64-linux-gnu/libIlmImf.so /usr/lib/x86_64-linux-gnu/libIex.so /usr/lib/x86_64-linux-gnu/libHalf.so /usr/lib/x86_64-linux-gnu/libIlmThread.so (ver 1.6.1)

  Video I/O:
    DC1394 1.x:                  NO
    DC1394 2.x:                  YES (ver 2.2.1)
    FFMPEG:                      YES
      codec:                     YES (ver 54.35.0)
      format:                    YES (ver 54.20.4)
      util:                      YES (ver 52.3.0)
      swscale:                   YES (ver 2.1.1)
      gentoo-style:              YES
    GStreamer:                   
      base:                      YES (ver 0.10.36)
      video:                     YES (ver 0.10.36)
      app:                       YES (ver 0.10.36)
      riff:                      YES (ver 0.10.36)
      pbutils:                   YES (ver 0.10.36)
    OpenNI:                      NO
    OpenNI PrimeSensor Modules:  NO
    PvAPI:                       NO
    GigEVisionSDK:               NO
    UniCap:                      NO
    UniCap ucil:                 NO
    V4L/V4L2:                    Using libv4l1 (ver 1.0.1) / libv4l2 (ver 1.0.1)
    XIMEA:                       NO
    Xine:                        NO

  Other third-party libraries:
    Use IPP:                     NO
    Use Eigen:                   YES (ver 3.2.0)
    Use TBB:                     YES (ver 4.2 interface 7000)
    Use OpenMP:                  NO
    Use GCD                      NO
    Use Concurrency              NO
    Use C=:                      NO
    Use Cuda:                    NO
    Use OpenCL:                  YES

  OpenCL:
    Version:                     dynamic
    Include path:                /home/gfolego/packages/opencv-2.4.11/3rdparty/include/opencl/1.2
    Use AMD FFT:                 NO
    Use AMD BLAS:                NO

  Python:
    Interpreter:                 /usr/bin/python2 (ver 2.7.6)
    Libraries:                   /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.6)
    numpy:                       /usr/local/lib/python2.7/dist-packages/numpy/core/include (ver 1.9.2)
    packages path:               lib/python2.7/dist-packages

  Java:
    ant:                         /usr/bin/ant (ver 1.9.3)
    JNI:                         /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include
    Java tests:                  YES

  Documentation:
    Build Documentation:         NO
    Sphinx:                      NO
    PdfLaTeX compiler:           /usr/bin/pdflatex
    Doxygen:                     YES (/usr/bin/doxygen)

  Tests and samples:
    Tests:                       YES
    Performance tests:           YES
    C/C++ Examples:              NO

  Install path:                  /home/gfolego/packages/opencv-2.4.11/release/installed

  cvconfig.h is in:              /home/gfolego/packages/opencv-2.4.11/release
-----------------------------------------------------------------


==31226== 
==31226== HEAP SUMMARY:
==31226==     in use at exit: 24,160 bytes in 60 blocks
==31226==   total heap usage: 92 allocs, 32 frees, 36,209 bytes allocated
==31226== 
==31226== 192 bytes in 1 blocks are possibly lost in loss record 1 of 12
==31226==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==31226==    by 0x671195B: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6711B70: tbb::internal::NFS_Allocate(unsigned long, unsigned long, void*) (in /usr/lib/libtbb.so.2)
==31226==    by 0x6716339: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719175: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x671987D: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719994: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719AE4: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719359: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6717800: tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const (in /usr/lib/libtbb.so.2)
==31226==    by 0x4F77CF9: cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_core.so.2.4.11)
==31226==    by 0x54A6B94: void cv::CvtColorLoop<cv::RGB2Gray<unsigned char> >(cv::Mat const&, cv::Mat&, cv::RGB2Gray<unsigned char> const&) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226== 
==31226== 384 bytes in 1 blocks are possibly lost in loss record 2 of 12
==31226==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==31226==    by 0x671195B: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6711B70: tbb::internal::NFS_Allocate(unsigned long, unsigned long, void*) (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719971: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719AE4: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719359: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6717800: tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const (in /usr/lib/libtbb.so.2)
==31226==    by 0x4F77CF9: cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_core.so.2.4.11)
==31226==    by 0x54A6B94: void cv::CvtColorLoop<cv::RGB2Gray<unsigned char> >(cv::Mat const&, cv::Mat&, cv::RGB2Gray<unsigned char> const&) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x54B846D: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x400E78: main (in /home/gfolego/projects/test/test)
==31226== 
==31226== 384 bytes in 1 blocks are possibly lost in loss record 3 of 12
==31226==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==31226==    by 0x671195B: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6711B70: tbb::internal::NFS_Allocate(unsigned long, unsigned long, void*) (in /usr/lib/libtbb.so.2)
==31226==    by 0x671B3F8: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x671B5BD: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719B02: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719359: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6717800: tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const (in /usr/lib/libtbb.so.2)
==31226==    by 0x4F77CF9: cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_core.so.2.4.11)
==31226==    by 0x54A6B94: void cv::CvtColorLoop<cv::RGB2Gray<unsigned char> >(cv::Mat const&, cv::Mat&, cv::RGB2Gray<unsigned char> const&) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x54B846D: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x400E78: main (in /home/gfolego/projects/test/test)
==31226== 
==31226== 384 bytes in 1 blocks are possibly lost in loss record 4 of 12
==31226==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==31226==    by 0x671195B: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6711B70: tbb::internal::NFS_Allocate(unsigned long, unsigned long, void*) (in /usr/lib/libtbb.so.2)
==31226==    by 0x671BD97: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x671BEF4: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x671D720: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x671C811: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719361: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6717800: tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const (in /usr/lib/libtbb.so.2)
==31226==    by 0x4F77CF9: cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_core.so.2.4.11)
==31226==    by 0x54A6B94: void cv::CvtColorLoop<cv::RGB2Gray<unsigned char> >(cv::Mat const&, cv::Mat&, cv::RGB2Gray<unsigned char> const&) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x54B846D: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226== 
==31226== 384 bytes in 1 blocks are possibly lost in loss record 5 of 12
==31226==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==31226==    by 0x671195B: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6711B70: tbb::internal::NFS_Allocate(unsigned long, unsigned long, void*) (in /usr/lib/libtbb.so.2)
==31226==    by 0x671BD97: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6717786: tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const (in /usr/lib/libtbb.so.2)
==31226==    by 0x4F77CF9: cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_core.so.2.4.11)
==31226==    by 0x54A6B94: void cv::CvtColorLoop<cv::RGB2Gray<unsigned char> >(cv::Mat const&, cv::Mat&, cv::RGB2Gray<unsigned char> const&) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x54B846D: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x400E78: main (in /home/gfolego/projects/test/test)
==31226== 
==31226== 384 bytes in 1 blocks are possibly lost in loss record 6 of 12
==31226==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==31226==    by 0x671195B: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6711B70: tbb::internal::NFS_Allocate(unsigned long, unsigned long, void*) (in /usr/lib/libtbb.so.2)
==31226==    by 0x671BD97: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x671CF12: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x4F77D50: cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_core.so.2.4.11)
==31226==    by 0x54A6B94: void cv::CvtColorLoop<cv::RGB2Gray<unsigned char> >(cv::Mat const&, cv::Mat&, cv::RGB2Gray<unsigned char> const&) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x54B846D: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x400E78: main (in /home/gfolego/projects/test/test)
==31226== 
==31226== 520 bytes in 1 blocks are possibly lost in loss record 7 of 12
==31226==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==31226==    by 0x671195B: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6711B70: tbb::internal::NFS_Allocate(unsigned long, unsigned long, void*) (in /usr/lib/libtbb.so.2)
==31226==    by 0x671D70A: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x671C811: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719361: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6717800: tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const (in /usr/lib/libtbb.so.2)
==31226==    by 0x4F77CF9: cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_core.so.2.4.11)
==31226==    by 0x54A6B94: void cv::CvtColorLoop<cv::RGB2Gray<unsigned char> >(cv::Mat const&, cv::Mat&, cv::RGB2Gray<unsigned char> const&) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x54B846D: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x400E78: main (in /home/gfolego/projects/test/test)
==31226== 
==31226== 1,024 bytes in 1 blocks are possibly lost in loss record 8 of 12
==31226==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==31226==    by 0x671195B: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6711B70: tbb::internal::NFS_Allocate(unsigned long, unsigned long, void*) (in /usr/lib/libtbb.so.2)
==31226==    by 0x6715CC1: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x671634C: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719175: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x671987D: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719994: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719AE4: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719359: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6717800: tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const (in /usr/lib/libtbb.so.2)
==31226==    by 0x4F77CF9: cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_core.so.2.4.11)
==31226== 
==31226== 1,536 bytes in 24 blocks are possibly lost in loss record 9 of 12
==31226==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==31226==    by 0x6711BC9: tbb::internal::allocate_via_handler_v3(unsigned long) (in /usr/lib/libtbb.so.2)
==31226==    by 0x671B2CB: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x671B5BD: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719B02: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719359: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6717800: tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const (in /usr/lib/libtbb.so.2)
==31226==    by 0x4F77CF9: cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_core.so.2.4.11)
==31226==    by 0x54A6B94: void cv::CvtColorLoop<cv::RGB2Gray<unsigned char> >(cv::Mat const&, cv::Mat&, cv::RGB2Gray<unsigned char> const&) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x54B846D: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x400E78: main (in /home/gfolego/projects/test/test)
==31226== 
==31226== 3,096 bytes in 3 blocks are possibly lost in loss record 10 of 12
==31226==    at 0x4C2B800: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==31226==    by 0x671B23B: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x671B5BD: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719B02: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719359: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6717800: tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const (in /usr/lib/libtbb.so.2)
==31226==    by 0x4F77CF9: cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_core.so.2.4.11)
==31226==    by 0x54A6B94: void cv::CvtColorLoop<cv::RGB2Gray<unsigned char> >(cv::Mat const&, cv::Mat&, cv::RGB2Gray<unsigned char> const&) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x54B846D: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x400E78: main (in /home/gfolego/projects/test/test)
==31226== 
==31226== 3,584 bytes in 1 blocks are possibly lost in loss record 11 of 12
==31226==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==31226==    by 0x671195B: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6711B70: tbb::internal::NFS_Allocate(unsigned long, unsigned long, void*) (in /usr/lib/libtbb.so.2)
==31226==    by 0x671B594: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719B02: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719359: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6717800: tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const (in /usr/lib/libtbb.so.2)
==31226==    by 0x4F77CF9: cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_core.so.2.4.11)
==31226==    by 0x54A6B94: void cv::CvtColorLoop<cv::RGB2Gray<unsigned char> >(cv::Mat const&, cv::Mat&, cv::RGB2Gray<unsigned char> const&) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x54B846D: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x400E78: main (in /home/gfolego/projects/test/test)
==31226== 
==31226== 12,288 bytes in 24 blocks are possibly lost in loss record 12 of 12
==31226==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==31226==    by 0x6711BC9: tbb::internal::allocate_via_handler_v3(unsigned long) (in /usr/lib/libtbb.so.2)
==31226==    by 0x671B2EC: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x671B5BD: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719B02: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6719359: ??? (in /usr/lib/libtbb.so.2)
==31226==    by 0x6717800: tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const (in /usr/lib/libtbb.so.2)
==31226==    by 0x4F77CF9: cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_core.so.2.4.11)
==31226==    by 0x54A6B94: void cv::CvtColorLoop<cv::RGB2Gray<unsigned char> >(cv::Mat const&, cv::Mat&, cv::RGB2Gray<unsigned char> const&) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x54B846D: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /home/gfolego/packages/opencv-2.4.11/release/installed/lib/libopencv_imgproc.so.2.4.11)
==31226==    by 0x400E78: main (in /home/gfolego/projects/test/test)
==31226== 
==31226== LEAK SUMMARY:
==31226==    definitely lost: 0 bytes in 0 blocks
==31226==    indirectly lost: 0 bytes in 0 blocks
==31226==      possibly lost: 24,160 bytes in 60 blocks
==31226==    still reachable: 0 bytes in 0 blocks
==31226==         suppressed: 0 bytes in 0 blocks
==31226== 
==31226== For counts of detected and suppressed errors, rerun with: -v
==31226== ERROR SUMMARY: 12 errors from 12 contexts (suppressed: 0 from 0)