.NET Garbage Collection PopQuiz

1 minute read

Time for a little pop-quiz/potential interview questions to get some action going in the comments section…

Note: This was back when my blog had comments

Feel free to answer any or all of the below questions, I’ll follow up with a post later if all of them are not answered…

  1. How many GC threads do we have in a .NET process running the Server version of the GC on a dual-core machine?
  2. What GC mode is used in the web development server (cassini) on a quad proc machine? Why? (you can choose from server, workstation or concurrent-workstation)
  3. How many finalizer threads do we have in a .NET process running the Server version of the GC on a quad proc machine?
  4. When is an object garbage collected?
  5. What causes an object to move from Generation 0 to Generation 1 or to Generation 2?
  6. If you look at the GC sizes for Generation 0, 1 and 2 in perfmon, why is most of the memory in the process in Gen 2?
  7. How many heaps will you have at startup on a 4 proc machine running the server GC? How many would you have if the same machine was running the workstation GC? Will the memory used for these show up in private bytes or virtual bytes in perfmon or both?
  8. (Leading question :)) Is the fact that you have mscorwks.dll loaded in the process in 2.0 an indication of that you are running the workstation version of the GC?
  9. Can you manually switch GC modes for a process? If so, how and under what circumstances?
  10. Name at least 2 ways to make objects survive GC collections unnecessarily.
  11. Can a .NET application have a real memory leak? In the C++ sense where we allocate a chunk of memory and throw away the handle/pointer to it?
  12. Why is it important to close database connections and dispose of objects? Doesn’t the GC take care of that for me?

and if you don’t think these questions are enough… feel free to post some of your own questions on the same theme…

Have fun, Tess