With a managed application, blocks of memory are allocated on the managed heap. (The heap is the part of memory that is used to store objects, as opposed to the stack, which is used to store references to objects— more on heap and stack later.) The GC keeps track of the referenced objects on the heap and automatically frees up the memory allocated to a specific object when it goes out of scope. Calling the GC programmatically is possible by invoking the method System.GC.Collect. However, this is not recommended because it is not guaranteed that it will destroy your objects. It is best to focus on the business logic and let the CLR determine the right time for garbage collection.
