What is the difference between stack and heap in MVC?

2 votes
131 views
Tarun Gautam asked 14-Nov-2017 in programming by Tarun Gautam

What is the difference between stack and heap in MVC?

1 Answer

0 votes
Arti Mishra answered 10-Sep-2018 by Arti Mishra

Difference between stack and heap in MVC

What is the difference between stack and heap in MVC?

Stack
  • 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
  • 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