Memory leak jetson-nano-jp46-sd-card-image

Hi
This is my test code:

#include <opencv2/opencv.hpp>
#include <QDebug>
int main()
{
    cv::VideoCapture camera(0);

    if (!camera.isOpened()) {
        qDebug() << "ERROR: Could not open camera";
        return 1;
    }

    cv::namedWindow("Webcam");
    cv::Mat frame;
    while (1)
    {
         camera >> frame;

        if (!frame.empty())
        {
             cv::imshow("Webcam", frame);

            if (cv::waitKey(10) >= 0)
                break;
        }
    }
    camera.release();
    return 0;
}

This is the test output log

ion@ion-desktop:~/build-testMemory-Desktop-Debug$ valgrind --leak-check=full --show-leak-kinds=all ./testMemory 
==25655== Memcheck, a memory error detector
==25655== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==25655== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==25655== Command: ./testMemory
==25655== 
[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (933) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1
Gtk-Message: 14:30:44.812: Failed to load module "canberra-gtk-module"
==25655== 
==25655== HEAP SUMMARY:
==25655==     in use at exit: 4,439,680 bytes in 34,707 blocks
==25655==   total heap usage: 83,816 allocs, 49,109 frees, 106,831,338 bytes allocated
==25655== 
==25655== 59 bytes in 1 blocks are indirectly lost in loss record 1 of 15
==25655==    at 0x4845BFC: malloc (in /usr/lib/valgrind/vgpreload_memcheck-arm64-linux.so)
==25655== 
==25655== 128 bytes in 1 blocks are still reachable in loss record 2 of 15
==25655==    at 0x48468F4: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-arm64-linux.so)
==25655== 
==25655== 208 bytes in 13 blocks are possibly lost in loss record 3 of 15
==25655==    at 0x4845B3C: malloc (in /usr/lib/valgrind/vgpreload_memcheck-arm64-linux.so)
==25655== 
==25655== 1,872 bytes in 4 blocks are possibly lost in loss record 4 of 15
==25655==    at 0x4847D10: realloc (in /usr/lib/valgrind/vgpreload_memcheck-arm64-linux.so)
==25655== 
==25655== 1,948 bytes in 21 blocks are still reachable in loss record 5 of 15
==25655==    at 0x484622C: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-arm64-linux.so)
==25655== 
==25655== 6,176 bytes in 193 blocks are still reachable in loss record 6 of 15
==25655==    at 0x5BE14BC: g_closure_new_simple (in /usr/lib/aarch64-linux-gnu/libgobject-2.0.so.0.5600.4)
==25655== 
==25655== 6,332 bytes in 50 blocks are possibly lost in loss record 7 of 15
==25655==    at 0x4847B0C: calloc (in /usr/lib/valgrind/vgpreload_memcheck-arm64-linux.so)
==25655== 
==25655== 7,952 bytes in 193 blocks are still reachable in loss record 8 of 15
==25655==    at 0x5BE1474: g_closure_new_simple (in /usr/lib/aarch64-linux-gnu/libgobject-2.0.so.0.5600.4)
==25655== 
==25655== 16,539 (16,480 direct, 59 indirect) bytes in 2 blocks are definitely lost in loss record 9 of 15
==25655==    at 0x4845BFC: malloc (in /usr/lib/valgrind/vgpreload_memcheck-arm64-linux.so)
==25655== 
==25655== 19,568 bytes in 753 blocks are still reachable in loss record 10 of 15
==25655==    at 0x5C07DDC: g_type_create_instance (in /usr/lib/aarch64-linux-gnu/libgobject-2.0.so.0.5600.4)
==25655== 
==25655== 38,788 bytes in 1,086 blocks are still reachable in loss record 11 of 15
==25655==    at 0x4845B3C: malloc (in /usr/lib/valgrind/vgpreload_memcheck-arm64-linux.so)
==25655== 
==25655== 160,008 bytes in 753 blocks are still reachable in loss record 12 of 15
==25655==    at 0x5C07D94: g_type_create_instance (in /usr/lib/aarch64-linux-gnu/libgobject-2.0.so.0.5600.4)
==25655== 
==25655== 241,637 bytes in 1,747 blocks are still reachable in loss record 13 of 15
==25655==    at 0x4847D10: realloc (in /usr/lib/valgrind/vgpreload_memcheck-arm64-linux.so)
==25655== 
==25655== 1,593,370 bytes in 25,888 blocks are still reachable in loss record 14 of 15
==25655==    at 0x4845BFC: malloc (in /usr/lib/valgrind/vgpreload_memcheck-arm64-linux.so)
==25655== 
==25655== 2,137,858 bytes in 3,056 blocks are still reachable in loss record 15 of 15
==25655==    at 0x4847B0C: calloc (in /usr/lib/valgrind/vgpreload_memcheck-arm64-linux.so)
==25655== 
==25655== LEAK SUMMARY:
==25655==    definitely lost: 16,480 bytes in 2 blocks
==25655==    indirectly lost: 59 bytes in 1 blocks
==25655==      possibly lost: 8,412 bytes in 67 blocks
==25655==    still reachable: 4,207,433 bytes in 33,691 blocks
==25655==                       of which reachable via heuristic:
==25655==                         length64           : 7,264 bytes in 115 blocks
==25655==                         newarray           : 2,144 bytes in 54 blocks
==25655==         suppressed: 0 bytes in 0 blocks
==25655== 
==25655== For counts of detected and suppressed errors, rerun with: -v
==25655== ERROR SUMMARY: 4 errors from 4 contexts (suppressed: 0 from 0)
ion@ion-desktop:~/build-testMemory-Desktop-Debug$ 

How can I fix this issue?
Thanks

Hi,
This would need other users to share experience. By default we have software stacks for gstreamer and jetson_multimedia_api. OpenCV is a 3rdparty software stack. May see if other users have seen it and can share suggestion.

Thank you for your reply.
Anyone else can help me sort it out? Thank you very much!