SPDisposeChecker, is this a false positive?
-
16-10-2019 - |
문제
We have the following code:
foreach (SPWeb website in collectionOfWebSites)
{
// Some code, no dispose of website
}
SPDisposeChecker is reporting it as a memory leak. Should we dispose the website at the end of the foreach?
해결책
Yes, dispose the SPWeb here each time!
다른 팁
Someone might need to back up me, but if you're getting an object from that collection, it does actually create an SPWeb instance each time (the collection is just a collection of object references rather than the objects themselves?), so you will indeed need to dispose of the object after each iteration.
제휴하지 않습니다 sharepoint.stackexchange