Memory leak in nvEncOpenEncodeSessionEx

when i use valgrind to check ffmpeg memory leak, it reports:
==2550== 32 bytes in 1 blocks are definitely lost in loss record 478 of 2,201
==2550== at 0x4C29F73: malloc (vg_replace_malloc.c:309)
==2550== by 0x57D3236D: ???
==2550== by 0x57D316D8: ???
==2550== by 0x57D212E1: ???
==2550== by 0x57D2EB3B: ???
==2550== by 0x802E8B8: nvenc_open_session (nvenc.c:237)
==2550== by 0x802F2A2: nvenc_check_device (nvenc.c:446)
==2550== by 0x802F7D6: nvenc_setup_device (nvenc.c:563)
==2550== by 0x8032CDC: ff_nvenc_encode_init (nvenc.c:1499)
==2550== by 0x81C5FC6: avcodec_open2 (utils.c:935)

it can be reproduced
dirver version:440
cuda version:10.2
in nvenc_open_session, it calls nvEncOpenEncodeSessionEx

Hi there @johnmca and welcome to the NVIDIA developer forums.

This is a known issue which was fixed end of 2021 in drivers starting with the 495 release train.

This is a non-critical issue which creates those 32 bytes once per encoder instance. Which means if you use for example ffmpeg command line tools, it will be cleaned up after the process ends. Only if you create a lot of encoder sessions within one process or start a lot of parallel processes for encoding will this be noticeable since it is only 32 bytes.

So I suggest you update your NVIDIA driver.

I hope that helps.

Thank you very much, it helps me a lot.

1 Like