Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How does Garbage collector(GC) works in .net

Answer Posted / viresh rajput

The Garbage Collector (GC) can be considered the heart of
the .NET Framework. It manages the allocation and release of
memory for any .NET application. In order to create good
.NET applications, we must know how the Garbage Collector
(GC) works.

All the living objects from the managed heap are divided in
three groups by their age. Those groups are generically
called "Generations". Those generations are very useful to
prevent memory fragmentation on the managed heap. The
Garbage Collector (GC) can search for dead object on each
generation at a time (partial collections), to improve the
collecting performance.

Now let’s see what the Garbage Collector (GC) is using each
generation for:

Generation 0 (Gen0) contains all the newly created
objects and it is located on the top of the heap zone
(higher memory addresses). All the objects contained by Gen0
are considered short-lived object and the Garbage Collector
(GC) is expecting to them to be quickly destroyed in order
to release the used memory space. Due to this presumption,
the Garbage Collector (GC) will try to collect dead objects
most often from Gen0 because it is cheapest.
Generation 1 (Gen1) contains all the living objects from
Gen0 that have survived to several Gen0 collects. So those
objects are upgraded from Generation 0 to Generation 1. Gen1
is defined in the middle of the heap zone and it is exposed
to fewer garbage collects than Gen0. Gen1’s collects are
more expensive than the Gen0’s so the Garbage Collector (GC)
will try to avoid them if it is not really necessary.
Generation 2 (Gen2) contains all the living objects from
Gen1 that have survived to several Gen2 collects. Those
objects are considered long-lived objects and destroying
them is very expensive. Because of this, the Garbage
Collector (GC) will hardly try to collect them. The Gen2
zone is located on the bottom of the managed heap zone
(lowest memory addresses).

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Describe the differences between the lifecycles of Windows services and Standard EXE?

1136


Is there any limit for query string? Means what is the maximum size?

922


What are themes and skins in 2.0, explain usage scenario?

910


What are navigation controls? How many navigation controls are there in ASP.NET 4.0?

922


Explain about ASP.NET?

1039


What is the use of autowireup in asp.net?

1026


Explain the differences between clr & cts?

957


What is the difference between page.registerclientscriptblock and page.registerstartupscript?

808


Why session is more secure than cookies?

870


What is the purpose of url encoding?

925


What are ASP.NET Web Forms? How is this technology different than what is available though ASP?

1604


How many types of validation are there?

915


Explain what are delegates?

1061


i want the asp.net technical questions and answeres

2024


Can you explain how ASP.NET application life cycle and page life cycle events fire?

981