Free all allocated memory on the device? Is there a way to free all the memory I allocated during a

Is there a Cuda function to Free all the memory on the device I allocated during my program?

Of cause I am very cautious to free every unused resources right ahead but during development its easy to miss to free some pointers.

As far as I know there is no such function. You need to take care of your memory allocation.

cudaDeviceReset() should do it.

cudaDeviceReset is specific to the context, right?

This function will destroy all the resources. I think that mapped PBOs will also be destroyed.

Thanks for your answers.


Explicitly cleans up all runtime-related resources associated with the calling host thread. Any subsequent API call reinitializes the runtime. cudaThreadExit() is implicitly called on host thread exit

api link

If I want to free some previously allocated memory instantly in the running process , how would I do that? I have used malloc and mallocpitch .

if you used cudaMalloc or cudaMallocPitch, you would use cudaFree to free those specific resources.

Thanks for reply, I have used that in my code but my question is, is it going to execute, i.e., instantly free memory during running process.