Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What will happen to the allocated memory on GPU, after the application using it exits, if cudaFree() was not used?

Tags:

cuda

gpgpu

If cudaFree() is not used in the end, will the memory being used automatically get free, after the application/kernel function using it exits?

like image 651
Buzz Avatar asked Sep 30 '15 02:09

Buzz


1 Answers

Yes.

When your application terminates (be it gracefully or not), all of its memory is reclaimed back by the OS, regardless of whether it had freed it or not. Similarly, the memory allocated on the GPU is managed by its driver, which will release all the resources your application held, cudaFreed or not.

It is however good practice that every allocation has a matching deallocation, so don't use that as an excuse to not deallocate your memory properly :)

like image 128
user703016 Avatar answered Sep 20 '22 13:09

user703016