when is the stack space and heap space freed in the program??
Stack space and heap space
stack space is freed when its scope gets over. Say a local variable was initialized within the main statically. So it will occupy the stack space. It is freed at the end of main.
heap space is freed using the delete keyword.(in C++)
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.