Wednesday, July 09, 2008

Writing performant code in SharePoint

This is an excerpt from SharePoint 2007: The definitive Guide,

Note that the SharePoint object model contains a number of managed objects – most importantly in this instance are SPWeb and SPSite - which use unmanaged code and memory to do the heavy lifting. If you create one of these objects yourself with the constructor method, you should make sure that you add in the necessary code to explicitly dispose of the object when you have finished using it. You can do this by explicitly calling the Dispose method or through the use of the C# using construct (as shown in the previous code listing). Failure to dispose of the object can result in unusual behavior such as high memory usage, frequent recycling of the SharePoint application pool, etc … It is recommended to use the Dispose method instead of simply calling the object’s Close method. 

For more info take a look at these must reads for every SharePoint developer:

1 comment:

Chester said...

HapiBlogging to you my friend! Have a nice day!