.NET Garbage Collection PopQuiz
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…
- How many GC threads do we have in a .NET process running the Server version of the GC on a dual-core machine?
- 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)
- How many finalizer threads do we have in a .NET process running the Server version of the GC on a quad proc machine?
- When is an object garbage collected?
- What causes an object to move from Generation 0 to Generation 1 or to Generation 2?
- 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?
- 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?
- (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?
- Can you manually switch GC modes for a process? If so, how and under what circumstances?
- Name at least 2 ways to make objects survive GC collections unnecessarily.
- 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?
- 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