下面的代码是否泄漏内存?如果是这样,有什么优化它的建议吗?
SPWeb web = (SPWeb)properties.Feature.Parent; // comes from the event receiver
//... lots of other code
// the below is the focal point.
foreach (SPWeb childWeb in web.Webs)
{
try
{
// lots of heavy processing with the childWebs
}
finally
{
if (childWeb != null)
{
childWeb.Dispose();
}
}
}