Although that might expose the programs to some exploits (give input that delays gc until OOM) .
In contrast, a garbage collector periodically detects that memory is no longer being used (e.g., an object that no existing object has pointers to), and automatically frees it. The programmer is not required to do anything to make this happen.
If you're talking about runtimes, and lower level work -- in the malloc/free world of C/C++ there isn't anything. If you allocate memory, that memory is allocated until you free it or your code exits. The OS isn't going to free your memory while your process is running, at least not that I'm aware of. You have to do it manually.
Then again, in some code it simply doesn't matter.
https://devblogs.microsoft.com/oldnewthing/20180228-00/?p=98...