How Garbage Collector identifies the objects which are not
in use?

Answers were Sorted based on User's Feedback



How Garbage Collector identifies the objects which are not in use?..

Answer / rahul veer

Garbage Collector determines which objects are no longer
being used by examining the application's roots. In Dot Net
each and every application has a set of roots. Each root
either refers to an object on the managed heap or is set to
null. An application's roots include global and static
object pointers, local variables and reference object
parameters on a thread's stack, and CPU registers. The
garbage collector has access to the list of active roots
that the just-in-time (JIT) compiler and the runtime
maintain. Using this list, it examines an application's
roots, and in the process creates a graph that contains all
the objects that are reachable from the roots. Objects that
are not in the graph are unreachable from the application's
roots. The garbage collector considers unreachable objects
as garbage and not in use.

Is This Answer Correct ?    10 Yes 1 No

How Garbage Collector identifies the objects which are not in use?..

Answer / sri

In the Dotnet CLR maintains the Heap. It stores the Objects
which are recently used in the Top of the Heap. By using
this GC identifies the objects which are recently used and
which are not in use.

Is This Answer Correct ?    11 Yes 8 No

How Garbage Collector identifies the objects which are not in use?..

Answer / bharani

GC identifies the objects which are not in use by the use
of generations. Whenever a new object is created or deleted
GC sweeps the heap by moving the variables to different
generations, and finally destructs the objects whichever
belongs to generation 0.

Is This Answer Correct ?    7 Yes 4 No

How Garbage Collector identifies the objects which are not in use?..

Answer / kiran vaidya

When any new object is created, it has two references
assigned, one is present on the application's stack area
and other is on the GC's stack. With creation of any new
object, it will be automatically assigned the generation as
0.
Now, there are two cases where object's reference is
removed from application stack.

1.When programmer assignes any object as 'null', the
reference on the application's stack to the specific object
is automatically removed.

2.When the function scope is ended, the references to those
objects in the function are automatically removed from
stack.
Now, GC compares the entries of references at its own
stack Vs the entries of references available at the
application stack.
By comparing them, it finds the object's references in
its stack to which, no match was found in the application
stack and releases memory allocated to them.

Is This Answer Correct ?    4 Yes 2 No

How Garbage Collector identifies the objects which are not in use?..

Answer / kanth

Garbage Collector identifies a unused object using "referce
counting"
reference countiing: how many times the object is used
if the count is zero..its is unuesd....now the gc will
release the resources..

Is This Answer Correct ?    5 Yes 6 No

How Garbage Collector identifies the objects which are not in use?..

Answer / anirudh menon

C# makes use of the Finilize() destructor for this purpose.
The CLR periodically checks the entire program for unused
objects using the refrence tracing garbage collector which
in turn invokes he Finilze() destructor to relese the
memory of such objects.

Is This Answer Correct ?    3 Yes 7 No

Post New Answer

More Dot Net Framework Interview Questions

Will the finally block get executed if an exception has not occurred

1 Answers   Siebel Systems,


will this code works fine? or will it gives error? Object obj=5; int i=6; i=i+obj;

9 Answers   Kanbay,


Difference between ASP.NET MVC and ASP.NET WebForms?

0 Answers  


What meant of assembly & global assembly cache (gac) & Meta data

1 Answers  


Is it possible to use multipe inheritance in .net

1 Answers  






differences between poco, model first and data first approach?

0 Answers   Microsoft,


what is msl?

0 Answers   Microsoft,


Is any files are generated,when we are adding the web reference to the web service?

2 Answers  


Difference between .NET & J2EE

1 Answers  


what are the aggregate functions in ASP.NET?

1 Answers   CTS, IBM, Zylog,


What is the advantage of mvc?

0 Answers  


Is it possible to combine asp.net webforms and asp.mvc and develop a single web application?

0 Answers  


Categories