need free memory?

When a program on CPU terminates, all memory freed by OS. What about GPU?
I’m learning CUDA and writing small programs. Sometimes I forget to free memory or terminate programs in the debugger, will this leave anything in the GPU, or affect further performance? I found my program’s performance varied alot on the same data set.

Yes, once your CUDA context is gone, the drivers clean everything up.
That context is deleted when your thread or process is. I think there’s a manual method too but you could look at the API to see for sure.