SharePoint Development Best Practices

In the last couple of months, I was bitten a couple times while creating some custom Web parts.  Duh..., I should have read Mike's article...If you are creating custom Web parts, you need to read this...go on...don't think about it.

Here is an excerpt...

...Several of the Windows SharePoint Services objects, primarily the SPSite class and SPWeb class objects, are created as managed objects. However, these objects use unmanaged code and memory to perform the majority of their work. The managed part of the object is small; the unmanaged part of the object is much larger. Because the smaller managed part of the object does not put memory pressure on the garbage collector, the garbage collector does not release the object from memory in a timely manner. The object's use of a large amount of unmanaged memory can cause some of the unusual behaviors described earlier. Calling applications that work with IDisposable objects in Windows SharePoint Services must dispose of the objects when the applications finish using them. You should not rely on the garbage collector to release them from memory automatically.  You can use any of several techniques to ensure that the objects are disposed of properly...

</steve>