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
What is tempdata?
How do I use partial view?
What is orm entity framework?
What is page life cycle?
How do I install .net framework?
What is attribute routing in mvc?
What is difference between razor and web form engine?
What is entity framework used for?
What is the .net framework and how does it work?
Mention what is the difference between “ActionResult” and “ViewResult” ?
what do you mean by navigation property?
what is entity framework?
Explain how to use multiple submit buttons in ASP.Net MVC?
What is the importance of NonActionAttribute?
Explain how you can send the result back in JSON format in MVC?