0
votes

What I don't understand is, people say when the current stack frame is returned, meaning under the hood in assembly, the esp moves up, so the memory in the stack frame will be freed.

How exactly does this chunk of memory get freed after moving the esp pointer? by runtime or os by checking nothing points at them?

2

2 Answers

2
votes

Free simply means that it's available for later use. Moving the stack pointer is sufficient to make everything past that point available for later use.

1
votes

Normally the stack is a one time allocation that remains until a program terminates, regardless of the values in EBP or ESP.