Too many open files while capturing frames using NVFBC

I’m trying to capture and encode frames using NvFBC and NvEncode APIs. When I keep running this for longer periods of time and capture frames, I see that over time the number of files opened keep increasing and resulting in unexpected behaviour of frame capturing.

When I check /var/log/messages, I’m seeing the below error being repeated.

pulseaudio[14910]: [pulseaudio] module-udev-detect.c: inotify_init1() failed: Too many open files
pulseaudio[14910]: [pulseaudio] module.c: Failed to load module "module-udev-detect" (argument: ""): initialization failed.
pulseaudio[14910]: [pulseaudio] main.c: Module load failed.
pulseaudio[14910]: [pulseaudio] main.c: Failed to initialize daemon.
pulseaudio[14906]: [pulseaudio] main.c: Daemon startup failed.

Also, when I check the number of files opened by the capture process, It shows 15822 files are opened by this process and I see /dev/nvidia0 file is opened very frequently. Here is the sample output I got, when I ran losf | grep [pid] command.

cuda-EvtH  3292 26285        pbsdata  418u  a_inode               0,10         0       6415 [eventfd]
cuda-EvtH  3292 26285        pbsdata  419u      CHR              195,0       0t0      44347 /dev/nvidia0
cuda-EvtH  3292 26285        pbsdata  420u      CHR              195,0       0t0      44347 /dev/nvidia0
cuda-EvtH  3292 26285        pbsdata  421u      CHR              195,0       0t0      44347 /dev/nvidia0
cuda-EvtH  3292 26285        pbsdata  422u      CHR              195,0       0t0      44347 /dev/nvidia0
cuda-EvtH  3292 26285        pbsdata  423u      CHR              195,0       0t0      44347 /dev/nvidia0
cuda-EvtH  3292 26285        pbsdata  424u      CHR              195,0       0t0      44347 /dev/nvidia0
cuda-EvtH  3292 26285        pbsdata  425u      CHR              195,0       0t0      44347 /dev/nvidia0

Out of 15822 files opened, nearly 14000 are opened by cuda-EvtH and approximately 1100 files by the capture process itself.

Could this be due to any possible memory leak on the process or driver side? I’m using NvFBC Linux API version 1.7 and NvEncode Linux API version 11.0.