Thursday, February 10, 2011

Dot net questions

What is Heap?A portion of memory reserved for a program to use for the temporary storage of data structures whose existence or size cannot be determined until the program is running.

What is Garbage Collection? How it works in Dot Net Framework?
Garbage collection is a system whereby a run-time component takes responsibility for managing the lifetime of objects and the heap memory that they occupy. Garbage Collection, which runs in the background collecting unused object references, freeing us from having to ensure we always destroy them. The garbage collector (GC) in .NET works without intervention of the developer ie. a developer does not have to track memory usage and worry about when to free memory. The Microsoft .NET CLR (Common Language Runtime) requires that all resources be allocated from the managed heap. The managed heap-objects are automatically freed when they are no longer needed by the application. GC in .Net is not deterministic that is, the .NET garbage collector works by periodically running through a list of all the objects that are currently being referenced by an application. All the objects that it doesn't find during this search are destroyed and the memory is freed up.

No comments:

Post a Comment