---
title: "What is the difference between stack and heap in MVC?"  
description: "What is the difference between stack and heap in MVC?"  
author: "Tarun Gautam"  
published: 2017-11-14  
canonical: https://answers.mindstick.com/qa/30541/what-is-the-difference-between-stack-and-heap-in-mvc  
category: "programming"  
tags: ["asp.net", ".net programming", "asp.net mvc"]  
reading_time: 1 minute  

---

# What is the difference between stack and heap in MVC?

What is the [difference](https://www.mindstick.com/blog/398/difference-between-object-type-and-var-type) between [stack](https://www.mindstick.com/blog/301746/why-is-stack-overflow-so-important-for-developers) and [heap](https://www.mindstick.com/forum/159150/what-happens-when-stack-and-heap-collide) in [MVC](https://www.mindstick.com/articles/1655/implementing-undo-in-asp-dot-net-webworm-s-and-mvc)?

## Answers

### Answer by Arti Mishra

## Difference between stack and heap in MVC

![What is the difference between stack and heap in MVC?](https://answers.mindstick.com/questionanswer/003aa1e3-9f3f-4fc7-80b7-31fb2e313422/images/1305c67c-eea5-45a7-9bf3-6ad62f89922b.gif)\
**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

\


---

Original Source: https://answers.mindstick.com/qa/30541/what-is-the-difference-between-stack-and-heap-in-mvc

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
