Stack space and heap space

when is the stack space and heap space freed in the program??

Hey @govilayush,
Stack space is used when the variables are statically defined and heap space is used when the variable is dynamically defined.
Heap space cannot delete the memory we have used by itself so we have to explicitly delete it once we have used the memory

Here is a blog to learn more about it , give it a read :blush:

Hope it helps ! Happy coding ! :blush: