Do I really need to free allocated memory? I know I should, but...


I’m wondering what will happen if I skip cudaFree(A) after allocating it?

Will the hardware free it automatically when a new kernel is loaded?
Will it just pile up until the system is shutdown?
Will it permanently damage the device, making me buy another card and make NVIDIA $800 richer?


as far as I know the data stays in memory as long as your host application (that starts the kernel) runs.

It will pile up until your application exits, or the total amount of RAM on your card is allocated, in which case new allocation calls will return 0. When your program exits the memory is returned to the system (like with normal malloc)