0

What is the meaning of this?

When a method is called, its return address and arguments are pushed onto a stack, and when it returns they’re popped off

player0
  • 124,011
  • 12
  • 67
  • 124
  • I'm not sure what you're asking. By the way "the stack" and stack [the data structure] are related but not the same thing. – harold Jul 14 '18 at 01:25

1 Answers1

0

Here is one example of a stack -- which is a visual representation of the resources a program uses in memory.

Stack of A running Process

Every program needs memory to store (at least): (A) - Local variables (B) - Routines (C) - A return address (where to go back from where it started).

Look at the example. If function DrawLine() was called in a program, a stack would be created to hold elements A through C in memory. When the function is done and complete, those temporary variables, addresses to function calls, and return address are no longer needed. Therefore, they are popped off of the stack to reduce memory consumption when complete.

Hope this is accurate and helpful...it is my first answer. If this answer is insufficient, consider the (likely duplicate) answer here: What and where are the stack heap?

Daniel Connelly
  • 206
  • 2
  • 10