NvBufferDestroy(): memory usage not decreasing

Hi,

Due to a memory leak issue on L4T 28.1 (https://devtalk.nvidia.com/default/topic/1044597/jetson-tx2/nvvideoencoder-repeated-start-stop-causes-crash-and-memory-leak) we moved our product to L4T 28.2 and modified the multimedia api code with the new features of 28.2 (x4 as we have 4 channels):
MIPI → DMABUF → NvBufferTransform() → Encoder DMABUF → Encoder capture plane.

In a test I started/stopped all 4 channels in a loop and checked memory usage, which still increases with the number of restarts.

Then I created a simple function which does the following in a loop:

  • Allocates 40 4k buffers (~660 mbytes)
  • Maps the buffers to pointer
  • Syncs the buffers to CPU
  • Writes some dummy data into the buffers
  • Syncs the buffer to device
  • Unmaps the buffers
  • Destroys the buffers
    The result is the same, memory usage (by tegrastats) increases wit every loop iteration.
    I also tried the same code on Jetson with the official L4T.

Test code: [url]https://1drv.ms/u/s!AlsRVJmJKD5JiPZG5ELrSOmtoxmUKA[/url]

Am I doing something wrong?
Thanks in advance.

Hi,
Please apply the prebuilt lib at
https://elinux.org/Jetson_TX2/28.2.1_patches
[MMAPI]Cannot run NvVideoDecoder in loop/Memory leak in NvVideoEncoder

Hi DaneLLL,

On the Jetson I already replaced libtegrav4l2.so in /usr/lib/aarch64-linux-gnu/tegra with the linked version.
The code I attached seems to have the issue with this library.

Regards,

Tessier

Hi,
Please try

ret_val = NvBufferMemUnMap(dmabuf_fd[i],
                                   0,
                                   (void**)&data_ptr[i]);

It should be &data_ptr[i]. Let’s correct this typo first.

Hi DaneLLL,

The simple test code works correctly now. I will update the library on the real system and give it a try.
I apologize for wasting your time with this stupid mistake.

Regards,

Tessier