Information Technology Reference
In-Depth Information
The Heap
The heap is an area where chunks of memory can be allocated to store certain kinds of data.
Unlike the stack, memory can be allocated and deallocated from the heap in any order.
Figure 3-7 shows a program that has allocated four items from the heap.
Figure 3-7. The memory heap
Although your program can allocate memory from the heap, it cannot deallocate it.
Instead, the CLR's Garbage Collector (GC) automatically cleans up orphaned heap objects
when it determines that your code will no longer access them. This frees you from what in
other programming languages can be an error-prone task. Figure 3-8 illustrates the garbage
collection process.
Figure 3-8. Automatic garbage collection in the heap
Search WWH ::




Custom Search