Back Forum Reply New

C sharp: differences between pile stack and heap

Post Last Edit by mek at 3-1-2010 14:57

Can anyone help explain about the differences between pile stack and heap in C# programming?
Post Last Edit by sok_senmonorom at 3-1-2010 15:27

The heap and the stack are the two places where programs store data.

The stack is a data structure in memory used for storing items in a last-in, first-out manner (LIFO).
The heap is a big chunk of memory that is managed by a heap manager.

With value types, if you declare them in a method, then they are on the
stack.

If they are fields in a class, then those are on the heap, because
the instance of the class itself is on the heap.

I'm not sure if 'pile' is any key word in C#. When talked about pile, I think it refers to stack.

MemoryContentsItem OrderItem Lifetime Item Removal
StackValue typesSequential (LIFO)scope pop
HeapObjectsRandomreference countGarbage Collection
Back Forum