What algorith does garbage collector uses,Why it is non -deteministic ????

Recently I faced an interview in which this question was asked
"What algorithm garbage collector uses and why its non-deterministic "
Please explain it...


Answer this question

What algorith does garbage collector uses,Why it is non -deteministic ????

  • JonathanNTU

    Thank you

    I tried to tell in a simple way.

    and the article is usefull.

    Im Sorry If I told wrong.


  • mgholam

    I understood like : what does garbage collector do

    So it manage memory system. for example u have to dispose your objects on runtime in old languages... becouse if u dont dispose.. memory will be full .. so Developer's mistake can stop your computer..
    Garbage Collector's work is that.. in .NET when u dispose an object.. its not mean it goes memory. Just u say garbage collector "This object is ready to dispose". and garbage collector dispose it when it is oke..
    U can ask.. why do we let GC (garbageCollector) to dispose objects..

    becouse to create 1000 objects.. and to dispose 1000 objects are not same.. to dispose takes more time. and it makes tires the computer.

    and u dont have to dispose the object.. becouse GC is smart. it understands u dont use that object and it dispose that...

    so GC works like this..


  • evil KID BUU

    Hi Ashok,

    Read through these two articles on MSDN Magazine as well, they provide a very thorough coverage of the Garbage Collection Topic and the article is by Jeffrey Ritchter

    1. Garbage Collection: Automatic Memory Management in the Microsoft .NET Framework - Part I
    http://msdn.microsoft.com/msdnmag/issues/1100/GCI/default.aspx

    2. Garbage Collection: Automatic Memory Management in the Microsoft .NET Framework - Part II
    http://msdn.microsoft.com/msdnmag/issues/1200/GCI2/default.aspx

    Regards,
    Vikram

  • tecmec

    can you tell more about ur question.


  • Niraj Sikotara

    UnquaLex,

    You seem to be mixing up finalization and disposing.

    To read up on how the garbarge collector works and finalization, read the following post by Chris Brumme http://blogs.msdn.com/cbrumme/archive/2004/02/20/77460.aspx.

    I also suggest that you read Applied Microsoft .NET Framework Programming, which has a entire chapter dedicated to the Garbarge Collection.



  • dsoto

    As through .net framework sdk I could know that an application can call garbage collector using the Collect method .I was asked to answer how this Collect function works i.e the algorithm...
    I am beginner .So I could not explain it.
    Is my question is clear to you now..
    Regards
    ashok

  • avishay_y

    Thanks Vikram...
    I will read it..
    regards
    ashok

  • newmaneh

    If you want even more info, check out the following episode of .NET Rocks. This was an interview with Chris Sells, one of the people who complained to Microsoft about the lack of clean-up optimization until the Dispose() pattern was implemented.

    http://www.dotnetrocks.com/default.aspx showID=10

  • terry62

    I think its great help for me....
    I will read the article ...
    Thanks for every thing..
    with regards
    ashok


  • What algorith does garbage collector uses,Why it is non -deteministic ????