Difference between stack and heap in MVC
- Stack is responsible for static memory allocation and it allocates the memory at compile time.
- It also follows the rules of LIFO (Last in First Out).
- In the stack, size limitation is varied according to the operating system.
- We can easily access the variables that are allocated on the stack and it takes less time.
- Heap is used for dynamic memory allocation and it allocates the memory at run time.
- In a heap, memory is allocated randomly.
- There is no limitation of size in a heap.
- In heap you can allocate or de-allocate the block any times as per user requirement.
- Accessing of the object is so difficult in comparison of stack and takes much more time