Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
When the garbage collector starts running, it makes the assumption that all objects in the heap are garbage. In other words, it assumes that none of the application's roots refer to any objects in the heap. Now, the garbage collector starts walking the roots and building a graph of all objects reachable from the roots.

What are the roots in this whole process???
Posted
Updated 6-Jan-14 5:17am
v2
Comments
Ron Beyer 5-Jan-14 23:41pm    
What language are we talking about? .NET? Java? Other? Please tag your post with the appropriate language tags.

1 solution

I'm not sure where you read that, but I would go through all these topics so you can fully understand .NET Garbage Collection:

MSDN .NET Garbage Collection[^]

If you don't read them all, at least read this one:

.NET Garbage Collection Fundamentals[^]
 
Share this answer
 
Comments
Parmod Jangra 9-Jan-14 12:23pm    
Thanks Ron for your quick reply. Please refer this link :
http://msdn.microsoft.com/en-us/magazine/bb985010.aspx
Ron Beyer 9-Jan-14 12:51pm    
That article is so old I wouldn't trust the information in it to apply to the newer versions of .NET. Its probably written for .NET 1.0 which was short lived.
Parmod Jangra 9-Jan-14 21:41pm    
Ok Ron, But an interviewer asked me this question so I am curious to find out this.
Ron Beyer 9-Jan-14 21:44pm    
I think your interviewer is confused on how .NET garbage collection works. The garbage collector does not rebuild the object graph each time it runs.
Parmod Jangra 9-Jan-14 22:36pm    
Ok, But first time how Gc knows which ojects are live or not?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900