If you are concerned that garbage collection affects performance, one of the best tools you can learn is the CLR Profiler . This utility allows you to profile the heap allocations performed by your program so that you can determine which methods generate the garbage. Remember that a lot of unobvious things can be singled out in a heap: combining strings, indexing dictionaries with enumerating keys, closing, delegation, etc. Even small garbage generated once per frame at 60 frames per second can stack up quickly under the right circumstances.
However, what you described does not seem like a garbage collection problem for me. GC is usually fast enough, even during a complete collection, to release only a few frames - in other words, you will notice a slight, annoying jerk every so often, but not a constant slowdown.
(Caution: this only applies to a PC that has a very complex GC compared to other XNA platforms.)
You should try connecting the profiler to your code to determine which methods take the longest; if your problem is not related to the GC, this may be informative. I used to use EQATEC , although I had problems with some of their later versions. You can try this, or you can look at Google for an alternative.
source share