Tuesday, 3 May 2011

Garbage Collection in asp.net

Short  :
  1. Garbage collection is a CLR feature which automatically release the  memory from the application .
  2. Programmers forget to release the objects while coding. CLR automatically releases objects when they are no longer referenced and in use. CLR runs on non-deterministic to see the unused objects and cleans them.
  3. The garbage collector (GC) completely absolves the developer from tracking memory usage and knowing when to free memory.
 ------------------------------------------------------------------------------------
Breifly :
Every program uses resources of one sort or another -- memory buffers, network connections, database resources and so on. In fact, in an object-oriented environment, every type identifies some resource available for a program's use. To use any of these resources, memory must be allocated to represent the type.

The steps required to access a resource are as follows:
1. Allocate memory for the type that represents the resource.
2. Initialize the memory to set the initial state of the resource and to make the resource usable.
3. Use the resource by accessing the instance members of the type (repeat as necessary).
4. Tear down the state of the resource to clean up.
5. Free the memory.

No comments:

Post a Comment