How Garbage Collector identifies the objects which are not
in use?
Answer Posted / 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 |
Post New Answer View All Answers
Explain the use of Inversion of control (IOC)?
What is a model in android?
How we can handle the exception at controller level in ASP.Net MVC?
What are the possible razor view extensions?
In .net compact framework, can we free memory explicitly without waiting for garbage collector to free the memory?
What is associationset? : Entity framework
how do you mark a property as required? For example, for a project, the name is a required field.
What is needed for running an application built on winfx on the .net framework 3.0?
what is ssdl?
What is the difference between partial and renderpartial?
What is the benefit of entity framework?
Explain entity lifecycle? : Entity framework
What are Validation Annotations?
what is explicit loading?
What is a razor file?