Wednesday, April 23, 2008

Stack vs Heap

Stock is a block of memory for storing local variable. The storage automatically grows and shrinks as a function is entered and exited.

Heap is a block of memory in which objects reside.Whenever a new object is created, it is allocated on the heap, and reference to that object is returned. During a program's execution, the heap starts filling up as new objects are created. The runtime has a garbage collector that periodically deallocates objects from the heap, so your computer does not runt out of memory. An object is eligible for dealocation as soon as nothing references it.

------ C#3.0 In A Nutshell by Joseph & Ben

No comments: