view more software Tips and Tricks
Updated: 06/26/2013 02:06 AM
Author: Shiju Mathews
Heap and the Stack are both stored in the computer’s RAM (Random Access Memory).
The Stack is more or less responsible for keeping track of what's executing in our code. The Heap is more or less responsible for keeping track of our objects.
There are two places the .NET framework stores items in memory as your code executes. If you haven't already met, let me introduce you to the Stack and the Heap. Both the stack and heap help us run our code.
Stack as like a series of boxes stacked one on top of the next. We can only use what's in the top box on the stack.
The Heap is similar except that its purpose is to hold information, so anything in our Heap can be accessed at any time.
The Stack is self-maintaining, meaning that it basically takes care of its own memory management. The Heap, on the other hand, has to worry about Garbage collection.
A Reference Type always goes on the Heap.
Value Types and Pointers always go where they were declared.