Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Search Your Question

Tuesday, May 6, 2008

What is garbage collection? How it works in .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:

Archives