L'importanza di usare il Dispose con SharePoint
Un interessante articolo sulle buone regole di programmazione in SharePoint (WSS3)
http://msdn2.microsoft.com/en-us/library/bb687949.aspx
In particolare la seguente nota
In the SharePoint object model, the Microsoft.SharePoint.SPSite and Microsoft.SharePoint.SPWeb objects are created in managed code as a small wrapper (approximately 2 KB in size). This wrapper then creates unmanaged objects, which can average approximately 1–2 MB in size. If your code resembles the following code example, and if you assume that the SPWeb.Webs collection has 10 subsites, a total of 10 items are created, each with an average of 2 MB of memory (for a total of 20 MB).
rende bene l'idea sull'occupazione di memoria degli oggetti, ben 2 MB per ogni SPSite ed SPWeb !!!! di codice non gestito.
Quindi, fate sempre il Dispose degli oggetti (tranne quelli ottenuti da SPContext).
Ad esempio
http://msdn2.microsoft.com/en-us/library/bb687949.aspx
In particolare la seguente nota
In the SharePoint object model, the Microsoft.SharePoint.SPSite and Microsoft.SharePoint.SPWeb objects are created in managed code as a small wrapper (approximately 2 KB in size). This wrapper then creates unmanaged objects, which can average approximately 1–2 MB in size. If your code resembles the following code example, and if you assume that the SPWeb.Webs collection has 10 subsites, a total of 10 items are created, each with an average of 2 MB of memory (for a total of 20 MB).
Quindi, fate sempre il Dispose degli oggetti (tranne quelli ottenuti da SPContext).
Ad esempio
C#
using(SPSite site = new SPSite(url)){
// codice ...
}