none
How approaches of the GC works? RRS feed

  • Question

  • Hi,

    I have gone through the GC. I am unable to grab the contents in MSDN. I have referred some sites.
    Finally, I have little confusion and queries.

    Could some one tell that, my understanding is correct?

    What I understood is:

    As shown above,the heap will be divided into 3 small heaps(Gen 0,1,2)
    and each of them will grow or shrink in size, according to the need.

    Inside each heap, there will be two region named, small object heap and large object heap.
    Of them the first 2 gen's are ephemeral(lasting for very small time - as synonym says).

    Clean-up  Approaches:-

    1. Concurrent Garbage Collector:-
    It will follow the "stop world" concept for the gen 0 and gen 1,since a small pause to the UI thread(who require the small space), will not make a big deal.  
    (A)"Question:" Is it a thread or normal function which will do this block mechanisms.?
    A separate thread will do the cleaning for the gen-2 and if any needed situation arises, it will block the UI thread when it requires a big space.
    And gen2's GC thread will run parallel to the UI thread, when there is a need for the garbage collection. That's why it is named as Concurrent.
    (B)Question:- These two garbage collection(G0,G1 and G2) process/threads will work parallel?

    2. Background Garbage Collector:-
    The ephemeral gen's are cleared by a separate thread (Foreground garbage collector thread and as usual it will block the UI thread if no enough space) and gen2 is cleared by seperate thread(C).
    And 2nd gen GC thread will pause and resume, based upon the state of the Foreground thread.

    (C)Question:- Is this thread will not perform the blocking call to the UI thread when some one requires a bulk space?
    (My Thinking and Query:- It will not block, as the name suggest, it will run in the background.
    But what if some one requires a large space and that space is not avail?. What approach it will follow?)

    Since it is a single concept, i have asked questions, instead of a seperate thread.

    Thanks in advance.


    NANDAKUMAR.T

    Saturday, June 27, 2015 5:39 PM

Answers

  • Hello NANDAKUMAR,

    For your questions:

    >>(A)"Question:" Is it a thread or normal function which will do this block mechanisms.?

    There is a dedicated thread that performs concurrent garbage collector for Gen 2.

    >>(B)Question:- These two garbage collection(G0,G1 and G2) process/threads will work parallel?

    Yes, it is, because for G0 and G1, it will run using these worker threads. For a more detail clarification, please check this link: Concurrent garbage collection.

    >>(C)Question:- Is this thread will not perform the blocking call to the UI thread when some one requires a bulk space?

    It depends on what Gen is collected, for both workstation or server garbage collections, if it is Gen2, then it would not block these worker threads all the time during the GC behavior, these threads could still allocate space. However, if the foreground garbage collection(G0 and G1) occurs, the UI thread could be block: Background workstation garbage collection and Background server garbage collection.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, June 29, 2015 7:05 AM
    Moderator