Q hinted at this a long while back. You keep what is necessary and delete what is not. In programming, garbage collection is the release of variables at the end of a task.
Say…
f=(0.5m)v^2
f is your global variable you have defined, while in this case m and v are locally defined variables, 0.5 is a constant.
When the computer loads these things into memory, to be processed, each of these variables take up space. F is in use elsewhere in the program and was computed for a reason, so you hang on to it. The other variables used for the computation are not needed, and should be released back to system memory to appropriate for other variables. This includes any interim stages - variables created within the stack by way of implementing machine language.
However… Let's say I was making a system call to run crypto. That means the key is stored somewhere in memory and invoked for the process, right? Are the positions in memory that have been declared as "garbage" rendered to a default 0/1? If no, then the potential to read them exists using various methods.