+ 2
What' the differences between heap and stack memory in java
3 Réponses
+ 4
𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 thank u🙏🙏
+ 4
Avinesh thank u🙏🙏
+ 2
Any object instantiated with a 'new' keyword gets memory allocated on the heap and the memory deallocation is taken care by the garbage collector in Java.
Also string literals are stored on the heap in a separate space known as String Constant Pool (SCP).
All the instance and local variables are allocated memory on the stack.
Also the stack memory is just few mb's whereas the heap is considered as infinite space of memory.