1.

What Is The Difference Between Stack Memory And Heap? Which One Is Faster?

Answer»

These are just two different memory areas used to store different kinds of VARIABLES. The stack is local to every thread while heap memory is shared among all threads. Since Stack is closer to thread and usually implemented using CPU registers they are faster than heap memory. The stack is used to store local variables as well method call frames while heap is used to store OBJECTS and class metadata. SEE the detailed ANSWER for more points.

These are just two different memory areas used to store different kinds of variables. The stack is local to every thread while heap memory is shared among all threads. Since Stack is closer to thread and usually implemented using CPU registers they are faster than heap memory. The stack is used to store local variables as well method call frames while heap is used to store objects and class metadata. See the detailed answer for more points.



Discussion

No Comment Found