Top 20 .NET Garbage Collection (GC) Articles
Jun 22, 07Ah. Garbage Collection… how I love and hate thee. 😛
I think one sad thing about programming in .net is that it seems many developers don’t know or care anything about garbage collection and memory management. You used to have to know about it in order to write bug free code. I suppose it is a two edge sword in that developers can develop faster as the intention was to relieve developers of the need to know or care anything about memory management. I personally have always tried to follow best practices for implementation and have tried to stay somewhat cautious of issues related to memory. I’ve been fortunate in never really having any memory management related issues in my previous applications. However, there, but for the grace of God, I too could go.
Recently, we have come across an issue that has required some intense scrutiny on our memory management process. Although it appears we are using mostly best practices for our access and use of certain objects (mainly in the System.Xml namespace) we are still running into memory problems. Unfortunately, our application includes some manual invocations of the GC.Collect() (EWWWWWWWW) to supposedly free up some of the memory consumed by some large objects.
Blah blah blah. The point is I have had to become a lot more familiar with garbage collection and memory management in general. I figured I would post what (I have found) to be the best sources for information on this topic, in the order I think it’s best to read them. Some of these refer to each other and I am merely following the order suggested by them. Others, I am simply including the order that seemed to make the most sense to me. I am extremely confident that after you read these articles, you will have a great handle on memory management and how the garbage collector work in .net.
I’m also including, as a bonus, this article which goes very deep into resource management using dispose and finalize. I went ahead and tagged this as architecture as well since I believe any good architect should want to know about the underlying framework.
Enjoy!
[edit] I’m going to tack a +1 onto this stack because I forgot I read this one somewhere between 1 and 6 and I found it helpful. If you read the above though, it’s not really necessary.