1.

What is stored in each of the memory structures- stack and heap, and how are they related to each other?

Answer»

The stack is a SECTION of memory that stores information about nested method (RECURSIVE)  calls all the WAY down to the present program location. It also holds all local variables and heap references defined in the currently running procedures. This structure enables the runtime to return from the method knowing the address from which it was invoked, as well as to remove all local variables when the procedure has been exited. EVERY thread has a stack of its own.

The heap is a big chunk of memory used for dynamic allocation. When you use the new keyword to create an object, it is allocated on the heap. The reference to this object, on the other hand, is stored on the stack.



Discussion

No Comment Found