Short Note in terms of compare Stack and Heap for Backend developers.

Parameter Stack Heap
Type of data structures A stack is a linear data structure. Heap is a hierarchical data structure.
Access speed
High-speed access Slower compared to stack
Access Local variables only (value type) It allows you to access variables globally (ref type).
Limit of space size
Limit on stack size dependent on OS. Does not have a specific limit on memory size.
Resize Variables cannot be resized Variables can be resized.
Memory Allocation Memory is allocated in a contiguous block. Memory is allocated in any random order.
Main Issue
Shortage of memory Memory fragmentation, Memory Leak

Bold text is important note.

More Detail

Stack vs Heap: Know the Difference
What is a Stack? A stack is a special area of computer’s memory which stores temporary variables created by a function. In stack, variables are declared, stored and initialized during runtime. It is a