I’m building an application where my CUDA program creates the cudaContext(using cudaFree(0)) waits for a file inside a folder , and when the file is created run the kernels and produce the output, and wait for the next file. I have it working but the problem is that the memory usage of the program is ridiculous. The amount of memory that it uses is for every file is about 112MB. So the amount of host memory it uses gets big really quickly. I’ve checked all my code for possible memory leaks and I couldn’t find them the only thing that I can think of is the cudaContext creates these memory locations every time the kernel runs and never lets them go. Is that a fair assumption? If so how can I fix this problem?