(1) source article from MSDN : Garbage Collector Basics and Performance Hints
“The .NET garbage collector provides a high-speed allocation service with good use of memory and no long-term fragmentation problems, however it is possible to do things that will give you much less than optimal performance.
To get the best out of the allocator you should consider practices such as the following:
- Allocate all of the memory (or as much as possible) to be used with a given data structure at the same time.
- Remove temporary allocations that can be avoided with little penalty in complexity.
- Minimize the number of times object pointers get written, especially those writes made to older objects.
- Reduce the density of pointers in your data structures.
- Make limited use of finalizers, and then only on “leaf” objects, as much as possible. Break objects if necessary to help with this.”
(2) source article : Memory Management Misconceptions
1. A garbage collector collects garbage
2. Doing lots of gen0 collections is bad
3. Performance counters are great for understanding what is happening
4. .NET doesn’t leak memory
5. All objects are treated the same
I believe they are highly recommended well-written articles. Enjoy! 🙂