You have a Web application that contains the following code segment.
private void CreatingSPSite()
{
SPSite siteCollection = null;
try
{
siteCollection = new SPSite(“http://contoso.com”);
}
finally
{
}
}
You need to prevent the code segment from causing a memory leak.
Which code segment should you add?
A.
if (siteCollection != null)
{
siteCollection.Close();
}
B.
if (siteCollection != null)
{
siteCollection.Dispose();
}
C.
siteCollection = null;
D.
siteCollection.WriteLocked = false;
Explanation:
MNEMONIC RULE: “Dispose of memory leak”Difference between Close() and Dispose() Method
http://dotnetguts.blogspot.com/2007/06/difference-between-close-and-dispose.html