192k views
3 votes
When does the memory space allocated to local variables and parameters get deallocated? When the application ends, the memory space allocated to local variables and parameters of both the called function and calling program is deallocated. O When the calling program ends, the memory space allocated to local variables and parameters of the called function is deallocated. When the called function ends, the memory space allocated to local variables and parameters of the calling program is deallocated. When the called function ends, the memory space allocated to local variables and parameters of the called function is deallocated. O

User Malinosqui
by
4.5k points

1 Answer

4 votes

Answer:

last option: When the called function ends, the memory space allocated to local variables and parameters of the called function is deallocated.

Step-by-step explanation:

A function, when it is called, uses the stack to allocate local variables. When it exits, those variables are no longer needed (since they are local), so the stack pointer is reset to the position it had before calling the function.

User Mark Thien
by
3.9k points