jawadalisoomro

Jawad Ali

Posted on June 16, 2024

Stack & Heap

Stack
fundamental data structure that operates on a Last In, First Out (LIFO) principle. It is analogous to a stack of plates where you can only access the topmost plate.
Heap
The heap is a region of memory used for dynamic memory allocation. It is a more flexible storage space where memory is allocated and deallocated manually (or automatically by a garbage collector in languages like Java or Python).

Stack works on primitive datatypes like int bool char etc
whereas
Heap works on non primitive datatypes like object and array

Stack make the copy of variable and it's original state remains same
whereas
Heap don't make the copy of original variable and if we change second instance the first instance automatically changes.

💖 💪 🙅 🚩
jawadalisoomro
Jawad Ali

Posted on June 16, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Stack & Heap
javascript Stack & Heap

June 16, 2024