UrbanPro
true

Learn .Net Advanced from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Garbage collector [ GC ] in .NET framework

Raga Deepthi G.
31/10/2018 0 0

Garbage collector [ GC ] is responsible for the "automatic memory management - AMM" in .NET framework. Garbage collector [ GC ] is one of the properties of .NET framework components CLR [ common language runtime ].

Why there is a need of "Memory management"?

Ans : Basically, Operating Sytem [ OS ] stores the data that is processed and accessed during programming / development of the applications in the memory. Sometimes that memory gets filled and developers may not be able to store the new data / input that is coming into. 

At this moment, developers need to write a seperate logic for the management of the memory, where they've to identify the unused or unnecessary data that has occupied the OS memory and need to write the logic for releasing that memory which is a burden for the developers.

Hence, to avoid the burden on the developers , this "automatic memory management" is needed.

In .NET, Garbage collector [ GC ] is responsible for the "automatic memory management" and it's popular for it's efficiency.

Working of Garbage collector [ GC ] : 

Garbage collector [ GC ] identifies the active and idled objects from the  heap memory , retains the active objects and destroys the idled objects and releases the memory. 

NOTE: GC provides automatic memory management only for "Reference types"

Generations of GC : 

Garbage collector [ GC ] divides the heap memory into 3 parts or generations and are named as Generation 0 , Generation 1 & Generation 2. Always Gen 0 > Gen 1 > Gen 2

Whenever a new object gets created , it occupies the memory only in Gen 0.

When Gen 0 gets filled completely, Garbage collector [ GC ] performs an action called "Collection" on Gen 0 , identifies the active and idled objects , pushes the active objects into Gen 1 and destroys the idled objects from the Gen 0 and releases the memory. 

 

When Gen 1 gets filled completely, Garbage collector [ GC ] performs an action called "Collection" on Gen 1 , identifies the active and idled objects , pushes the active objects into Gen 2 and destroys the idled objects from the Gen 1 and releases the memory. 

When Gen 2 gets filled completely, Garbage collector [ GC ] performs an action called "Collection" on Gen 2 , identifies the active and idled objects , retains the active objects and destroys the idled objects from the Gen 2 and releases the memory. 

Thus , Garbage collector [ GC ]  is efficient and responsible for "Automatic memory management" in .NET framework.

 

0 Dislike
Follow 2

Please Enter a comment

Submit

Other Lessons for You

Read CSV data using ODBC Connection
Codes to read the CSV data using ODBC Connection- Input File: File's Encoding format should be ANSI as below class Student{ public string CollegeId { get; set; } public string AdmissionDate...

Benefits of AsP.net webapi over traditional asp.net 2 and 3.5
Tradional asp.net had slower server side response feedback to the server with the MVC concept on webapi there were faster responses from the server side for client requests. Optimization of code was main...

Format Date to “MM/dd/yyyy” in Webgrid ASP.Net MVC Razor View
Replace above line with below to apply ("DD/mm/yyyy") formatting to date field in WebGrid AllTicket.Column(columnName: "DueDate", header: "Due Date") grid.Column("Date",format:@<text> @item.Date.ToString("MM/dd/yyyy")</text>)
M

Mohammad Shafi

0 0
0

Trends in .Net Platform
.NET Framework is a software framework developed by Microsoft. It includes a large class library named Framework Class Library (FCL) and provides language interoperability (each language can use code written...

Export To Excel using StringBuilder in ASP.net MVC C#
public ActionResult Export() { StringBuilder sb = new StringBuilder(); //static file name, can be changes as per requirement string sFileName = "filename.xls"; //Bind...
M

Mohammad Shafi

1 0
1
X

Looking for .Net Advanced Classes?

The best tutors for .Net Advanced Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn .Net Advanced with the Best Tutors

The best Tutors for .Net Advanced Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more