GC is the process whereby the Common Language Runtime (CLR) reclaims memory that is no longer in use—i.e., no longer referenced by an active object. Objects on the heap are garbage collected after the final reference to them is destroyed. The exact moment of collection is determined by the CLR. Memory for stack values is freed up immediately when the stack frame in which they are declared ends—e.g., when a method returns.
Source: i refer many site | Asked In: Many Interviews |