What is the difference between the Heap and the Stack?
The main difference b/n the Heap and the Stack are given below:
1.In stack we create object temporary where programmer used to reserve allocation.'
2.stack not have automatic garbage collection where as heap have automatic garbage collection.
Stack is volatile memory which uses RAM. where as heap is managed by GC. Stack holds values and heap holds references
Stack provides temporary memory allocation,or v can say it stores local variables whose default value is garbage,if not initialised.
Whereas heap provides dynamic memory allocation,or memory at run time.