-----------------------------------------------------------

New Message on MumbaiUserGroup

-----------------------------------------------------------
From: Swapnil_B1
Message 1 in Discussion

  Garbage Collector - Generations and Performance 
To optimize the performance of the garbage collector, the managed heap is 
divided into three generations: 0, 1, and 2. The runtime's garbage collection 
algorithm is based on several generalizations that the computer software 
industry has discovered to be true by experimenting with garbage collection 
schemes. First, it is faster to compact the memory for a portion of the managed 
heap than for the entire managed heap. Secondly, newer objects will have 
shorter lifetimes and older objects will have longer lifetimes. Lastly, newer 
objects tend to be related to each other and accessed by the application around 
the same time.  
The runtime's garbage collector stores new objects in generation 0. Objects 
created early in the application's lifetime that survive collections are 
promoted and stored in generations 1 and 2. The process of object promotion is 
described later in this topic. Because it is faster to compact a portion of the 
managed heap than the entire heap, this scheme allows the garbage collector to 
release the memory in a specific generation rather than release the memory for 
the entire managed heap each time it performs a collection.  
In reality, the garbage collector performs a collection when generation 0 is 
full. If an application attempts to create a new object when generation 0 is 
full, the garbage collector discovers that there is no address space remaining 
in generation 0 to allocate for the object. The garbage collector performs a 
collection in an attempt to free address space in generation 0 for the object. 
The garbage collector starts by examining the objects in generation 0 rather 
than all objects in the managed heap. This is the most efficient approach, 
because new objects tend to have short lifetimes, and it is expected that many 
of the objects in generation 0 will no longer be in use by the application when 
a collection is performed. In addition, a collection of generation 0 alone 
often reclaims enough memory to allow the application to continue creating new 
objects.  
After the garbage collector performs a collection of generation 0, it compacts 
the memory for the reachable objects as explained in Releasing Memory earlier 
in this topic. The garbage collector then promotes these objects and considers 
this portion of the managed heap generation 1. Because objects that survive 
collections tend to have longer lifetimes, it makes sense to promote them to a 
higher generation. As a result, the garbage collector does not have to 
reexamine the objects in generations 1 and 2 each time it performs a collection 
of generation 0.  
After the garbage collector performs its first collection of generation 0 and 
promotes the reachable objects to generation 1, it considers the remainder of 
the managed heap generation 0. It continues to allocate memory for new objects 
in generation 0 until generation 0 is full and it is necessary to perform 
another collection. At this point, the garbage collector's optimizing engine 
determines whether it is necessary to examine the objects in older generations. 
For example, if a collection of generation 0 does not reclaim enough memory for 
the application to successfully complete its attempt to create a new object, 
the garbage collector can perform a collection of generation 1, then generation 
0. If this does not reclaim enough memory, the garbage collector can perform a 
collection of generations 2, 1, and 0. After each collection, the garbage 
collector compacts the reachable objects in generation 0 and promotes them to 
generation 1. Objects in generation 1 that survive collections are promoted to 
generation 2. Because the garbage collector supports only three generations, 
objects in generation 2 that survive a collection remain in generation 2 until 
they are determined to be unreachable in a future collection.  
Swapnil (Swaps)  
http://swapsnet.spaces.live.com/

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/MumbaiUserGroup/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to