How does Garbage collector(GC) works in .net

Answer Posted / vikas rawat

Garbage CollectorMark-sweep algorithm)
If there is any memory defeciency then only GC will called
by CLR.
Low priority thread its run on its own thread.
It calls JIT compiler.
It maintains Apps_route table there all the objects are
maintained.those will seen by garbage collector
3 types of objects:
1. Short Leaved Objects/young objects
 Objects which are less referenced.
2. Long Leaved Objects/Older Objects
Objects which referenced more
3. Oldest Objects
Objects which are globally accessed
It maintain these objects in to 3 Generations:
Gen0 Gen1 Gen3
promote to --> promote to -->
contains object1 contains object2 contains object3

First goes to Gen-0::
If any object is used then it swaps/promote that object to
Gen-1.otherwise it destroys that object immediately.
Same will happen for Gen-1
Still the memory is adequate then it goes to Gen-2
Still memory is adequate it raise exception
memory insufficient exception
This is called as Non-Deterministic Finalization.

GC destroys only Managed Objects only not UNManaged Objects
Determenistic Finalization queue.
In this
Supress Finalize:: in this destructors will not CALLED


UnManaged Objects:


1.ADO.Net
2.Networking/Socket Programming.
3.IO(File Handling)
4.RCW / CCW / PIS

All the classes can have
 Close()/dispose()

We have to call them after completion objects usage.

Is This Answer Correct ?    17 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do sessions work?

540


What is the difference between session and application?

509


How do I use a proxy server when invoking a web service?

528


What is the purpose of url encoding?

498


Explain the role of global.asax?

555






What are web beacons used for?

550


Explain how can we inherit a static member?

534


What does clearing cache?

540


code for "For every 5days system has to create 1text file with the corresponding date and it has to store in c-drive" by using web applications

1413


What do you mean by authentication?

528


What is class and object in asp.net?

494


Define static member?

541


Define session in asp.net.

561


if i want to give an alert message like "try after sometime" to a web page which is being seen by other person.if a web page is not seen by anyone then it should display otherwise it show a display a message stating that other person is viewing so try after some time........how can i implement this.

1841


What is application and session in asp.net?

538