cudaGraphicsMapResources cause memoryLeak?

just call map and unmap:

checkCudaErrors(cudaGraphicsMapResources(1, &cuda_resource, 0));
checkCudaErrors(cudaGraphicsUnmapResources(1, &cuda_resource, 0));

then the memory used by the process increased about 1000KB, why?

I don’t happen to know the reason, but there are many things in CUDA that use up memory.

A single instance of a call for me does not give enough data to declare a memory leak.

If you called that sequence over and over, and each time you called it, the memory usage increased by 1000KB, and never decreased, and eventually you hit an out of memory (or some other error) then that would be a solid indication of a memory “leak”. But just because you called a routine once, and witnessed an increase in memory usage, does not give enough data to suggest a memory leak.

I think it’s quite possible that various activities in CUDA/Graphics interop will use additional memory that would not otherwise get used if you were not using CUDA/Graphics interop. But that by itself is not an observation that indicates a memory leak, from my point of view.

1 Like

this is happen when using CUDA-OpenGL interop.
is there any tool or good way to detect the leak location?

valgrind can detect cpu memory errors.

Memory Leak when using cuGraphicsD3D9RegisterResource - CUDA / CUDA Programming and Performance - NVIDIA Developer Forums
Consuming an EGLStream from CUDA causes memory bloat - Jetson & Embedded Systems / Jetson TX2 - NVIDIA Developer Forums
similar problems…
and tested cuda11.1 to 11.8, all leak…
map/unmap, release texture, resetDevice, Loop this , eg. 1million times, the memory keep increasing.
also tested put register/unregister in the Loop.

Hi, I found the same issue, Has it been solved ?