As a SharePoint developer, I have learned many things the hard way.  One of the most important things that I learned early on was to dispose of your SPSite and SPWeb objects.  They do not dispose cleanly on their own.  If you have custom code that is being called hundreds or thousands of times a day, then your application will more than likely crash IIS.

There are 2 main ways that I have seen developers dispose of these objects.  The first is to call the Dispose() method on each object.  The second, I think, is the best method, and that is to use the Using statement.  It makes it impossible to forget to dispose of the objects.  Here's how to use it...

<code> </code>
<pre><code>using (SPSite site = new SPSite("http://www.myserver.com")) {
     using (SPWeb web = SPSite.OpenWeb()) {
          //Your code here!
     </code>}
}</pre>
If you put all of your code where the "//Your code here!" statement is then you will never have to worry about disposing of the objects.  Even if the code throws an exception, the objects will be disposed of.  However, you should still put try-catch statements around your code to catch any errors that may occur.

If you need help checking your code for non-disposed objects, then check the <a title="SPDisposeCheck" href="http://code.msdn.microsoft.com/SPDisposeCheck" target="_blank">SPDisposeCheck</a> tool out.