Wednesday, January 20, 2010

WPF Threads

Learn about how WPF handles threads. WPF now offers two UI threads. Click on WPF Threads
and WPF Threading Model to learn more....

Memory Leaks with Delegates

When adding delegate (+=), you should remove it (-=) in order to release the delegate object and allow the GC to collect it. If a delegate maintains a reference to an externally declared object, and is not removed (-=), you will have a memory leak. For more details, click this article.

Thursday, January 7, 2010

Improve Garbage Collector Performance using Finalize/Dispose pattern

After reading an article that demonstrated how to improve GC performance (i.e., maximize size of Gen 0, minimize Gen 1 and Gen 2), I will refer to the Dispose pattern documentation on Microsoft site. The GC article is a good starting point and can be complemented by reading the Garbage Collection chapter in the "CLR via C#" book (i.e., where you will learn that large objects get placed directly on Gen 2 and more details not mentioned in this GC article).

It is very important to understand and implement the Dispose pattern correctly. If you do not, your application may do mysterious things, and it will not be the GC fault.

For details about Garbage Collector internals and more, read CLR via C# book (note in Feb 2010, Third edition of this book will be released).

For improving performance of your .NET applications check out the Microsoft Patterns and Practices.