Memory leak when nvv4l2decoder with drop-frame-interval param

• Hardware Platform: Jetson Xavier NX 16G
• JetPack Version: 4.6
I’m using opencv4.6 cv::videoCapture capi with gstreamer backend to capture ip camera video stream (no audio), when I add a drop-frame-interval=25 param, the process has a memory leak for about 2.5%(400M) every 6 hours.

I’ve tried rtsp and rtmp streams, the memory leak only shows when i add drop-frame-interval param for nvv4l2decoder, here are my pipelines for rtsp and rtmp:

rtspsrc location=rtsp://url?tcp latency=0 ! rtph264depay ! h264parse ! nvv4l2decoder drop-frame-interval=25 enable-max-performance=0 ! nvvidconv ! video/x-raw, format=BGRx ! videoconvert ! appsink sync=false

rtmpsrc location="rtmp://localhost/webcam/219 live=1" ! flvdemux ! h264parse ! nvv4l2decoder skip-frames=2 enable-max-performance=0 ! nvvidconv ! video/x-raw, format=BGRx ! videoconvert ! appsink sync=false

I’ve tried gst-launch-1.0 cmd with GST_TRACERS=“leaks”, the output shows memory leak too, but I can’t really get more informations from the it. Also the gst-launch-1.0 process didn’t really show a significant leak like my c++ program, there were only 0.1% memory increase after 3 hours test.

In other case I use nvv4l2decoder skip-frames=2 or drop frames in my c++ code, so I think my code should be fine. I’ve checked the opencv gst backend implement, but can’t really get much information.
Any similar problems or how can I debug with this? (like getting useful imformation with GST_TRACERS=“leaks”)

Which Deepstream version did you use? We have fixed many memory leak problem in the latest version, 6.1.1. You can try to upgrade it.

You can refer the link below:
https://forums.developer.nvidia.com/t/deepstream-sdk-faq/80236/14

Hmmm… I’m not using Deepstream SDK at all, just gstreamer in opencv.
Deepstream surely looks functional, but it should take time to modify my current work.

If there aren’t more experence about my current problem, I may try Deepstream SDK later. Do I have to upgrade my jetpack to 5.0.2 to use the latest DS?That could be a problem too since there will be environment change and i have more than one to upgrade.

Well, i still hope to solve my current problem.

Cause the nvv4l2decoder plugin provided by Deepstream, you need to update Deepstream to update the latest nvv4l2decoder plugin. So we sugguet you to update the Deepstream version to update the nvv4l2decoder plugin to fix some memory leak problem.

Oh I see, I didn’t really know that. I’ll try to update and probably reply the result next week.

Please let us know if you still need further support, thanks.

We were short of equipment last week, the only NX board had other tasks so we haven’t try to upgrade. Several NX board arrived just today and one of them is upgrading to 5.0.2. I’ll surely repley the result weather good or not, thanks for your follow up.

We’ve update the jetpack and deepstream and still get the same problem.
With the cmd deepstream-app --version-all I can get the output bellow:

deepstream-app version 6.1.1
DeepStreamSDK 6.1.1
CUDA Driver Version: 11.4
CUDA Runtime Version: 11.4
TensorRT Version: 8.4
cuDNN Version: 8.4
libNVWarp360 Version: 2.0.1d3

Since the application scenarios allows, we will temporarily schedule regular restart to prevent too much memory leaks.

Here are some simple test codes if you still wanted to help and reproduce the problem.
Replace the “drop-frame-interval=25” in test.cpp with “skip-frames=2” and you can get a program with out memory leak.

CMakeLists.txt

project(test)
cmake_minimum_required(VERSION 2.8.7)

find_package(OpenCV REQUIRED)
add_executable(test test.cpp)
target_link_libraries(test ${OpenCV_LIBS})
set(CMAKE_CXX_FLAGS "-std=c++0x")

test.cpp

#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/videoio.hpp>

int main()
{
        cv::Mat img;
        cv::VideoCapture cap;
        cap.open("rtmpsrc location=\"rtmp://url live=1\" ! flvdemux ! h264parse ! nvv4l2decoder drop-frame-interval=25 enable-max-performance=0 ! nvvidconv ! video/x-raw, format=BGRx ! videoconvert ! appsink sync=false", cv::CAP_GSTREAMER);
        if (!cap.isOpened()) {
                std::cout << "Can't open camera";
        }
        for (int i; true; i++) {
                if (cap.grab()) {
                        cap.retrieve(img);
                        std::cout << "Get frame " << i << std::endl;
                } else {
                        std::cout << "No frame " << i << std::endl;
                }
        }
}

There is no update from you for a period, assuming this is not an issue anymore. Hence we are closing this topic. If need further support, please open a new one.
Thanks

Thanks. Could you change the appsink to fakesink and test it again?
I use thegst-launch-1.0 cli to run the pipeline to exclude other possibilities. Like: gst-launch-1.0 rtmpsrc location=\"rtmp://url live=1\" ! flvdemux ! h264parse ! nvv4l2decoder drop-frame-interval=25 enable-max-performance=0 ! nvvidconv ! video/x-raw, format=BGRx ! videoconvert ! fakesink sync=false

You can use the script below to location it:
https://forums.developer.nvidia.com/t/deepstream-sdk-faq/80236/14

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.