0
下面的代码是否泄漏内存?如果是的话,有关优化它的任何建议?以下MOSS 2007代码可能会导致内存泄漏?
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();
}
}
}
感谢您的支票。我只用childWeb做很轻的处理,例如获取列表。我当时很妄想,在网页上做foreach可能会导致泄漏,因为在一些失败的代码之后,整个浏览器似乎在再次恢复生命之前就会停留在检测代理设置上。我认为这可能是由于内存泄漏导致的IISreset。 – BeraCim 2012-04-26 07:08:19
好的,没问题。您始终可以在任务管理器中监视w3wp进程,以查看它是否实际执行iisreset,在这种情况下,该进程的内存使用量应该下降。 – 2012-04-26 07:11:42
哦,顺便说一句,如果我的回答是有帮助的,请标记为答案.. – 2012-04-26 07:31:22