Nvv4l2decoder memory leak

***Jetpack 4.5.1 [L4T 32.5.2]
***xavier nx

hi, When I use nvv4l2decoder to decode, I find that there is a memory leak.
I use the following command:

GST_TRACERS=‘leaks’ GST_DEBUG=‘GST_TRACER:7’ gst-launch-1.0 filesrc location=z32.mp4 ! qtdemux ! h264parse ! nvv4l2decoder ! fakesink sync=false

and the output like this:
0:00:20.497944238 31808 0x5598d7b180 TRACE GST_TRACER :0:: object-alive, type-name=(string)(null), address=(gpointer)0x7f5806a650, description=(string)0x7f5806a650, ref-count=(uint)0, trace=(string);
0:00:20.497973678 31808 0x5598d7b180 TRACE GST_TRACER :0:: object-alive, type-name=(string)(null), address=(gpointer)0x7f58005970, description=(string)0x7f58005970, ref-count=(uint)0, trace=(string);

** (gst-launch-1.0:31808): WARNING **: 16:47:49.821: Leaks detected

When I replace nvv4l2decoder with omxh264dec, the memory leak disappears, I need some help.

Hi,
Please apply this patch and rebuild/replace nvv4l2decoder:
Jetson/L4T/r32.6.x patches - eLinux.org

[gstreamer] Memory leak in UDP streaming

And check if the warning disappears. This is a known leak.

I have added a patch, But when I used a real rtsp camera, I found a warning.
GST_TRACERS=‘leaks’ GST_DEBUG=‘GST_TRACER:7’ gst-launch-1.0 rtspsrc locati
on=rtsp://192.168.1.160:8554/0 ! rtph264depay ! h264parse ! nvv4l2decoder ! fakesink

GST_TRACER :0:: object-alive, type-name=(string)GstCaps, address=(
gpointer)0x7f6c003940, description=(string)video/x-raw(memory:NVMM), format=(string)NV12, width=(int)3840, height=(int)2160
, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/r
ight-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)
1/1, chroma-site=(string)mpeg2, colorimetry=(string)bt2020, framerate=(fraction)0/1, ref-count=(uint)1, trace=(string);

** (gst-launch-1.0:10702): WARNING **: 09:53:08.623: Leaks detected

When I replace nvv4l2decoder with omxh264dec, the memory leak disappears too., Is my step wrong?

Hi,
Probably it is another issue. Could you try Jetpack 4.6.2 and check if the warning is still present?

I have tested version 4.6.2, and it seems that there is no problem, thanks.

However, I cannot upgrade from version 4.5 to version 4.6, because many devices using nx have been deployed, and it is not allowed to upgrade too much. In addition, many of our codes are based on Tensorrt7, and migration with Tensorrt8 has failed. Now I have to use the patch to fix the bug .The memory used by programs keeps growing. The system will end the program after it runs for about a week. I wonder if I can fix this problem on version 4.5. Please help me.

Hi,
Please build libgstnvvideo4linux2.so of Jetpack 4.6.2 on Xavier NX/Jetpack 4.5, and replace it to

/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvvideo4linux2.so

See if it is good to replace latest lib to 4.5 and work fine. If it works, please check if this issue is present or disappears.

This is not tested so please backup original so file.

Thanks for your help. I’ll try. I need to observe the memory usage for a few days and see if it works.

The new version of the library cannot be used in version 4.5.2 and is incompatible

Progress: (connect) Connecting to rtsp://192.168.1.160:8554/0
Progress: (open) Retrieving server options
Progress: (open) Retrieving media info
Progress: (request) SETUP stream 0
Progress: (open) Opened Stream
Setting pipeline to PLAYING …
New clock: GstSystemClock
Progress: (request) Sending PLAY request
Progress: (request) Sending PLAY request
Progress: (request) Sent PLAY request
NvMMLiteOpen : Block : BlockType = 261
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 261
NvMMLiteOpen : Block : BlockType = 261
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 261
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame

Screenshot_20220928_164916

The program appears to be running, but the hardware decoding is not executed, I don’t know what else to do now.

Hi,
Please try this on Jetpack 4.5:
Memory Leak (Alloc/free mismatch) in Tegra multimedia API (encoder) - #6 by DaneLLL

It is still highly recommended if you can upgrade.

Thank you very much for your patient help. It really helped me a lot. I will continue to try other solutions. Thank you again.

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