MemoryLeak in Basic Web Player

Topics: Developer Forum, Project Management Forum
Jun 7, 2012 at 3:26 PM

There is a memory leak in method

CachedPackage.cs:793

private static DateTime GetLastModifiedTime(CachedFileInfo fileInfo)

Usage of "fileInfo.SPFile.TimeLastModified" outside USING scopes o SPWeb and SPSite initiates anotret SPRequest. I prefer method written like this:

        private static DateTime GetLastModifiedTime(CachedFileInfo fileInfo)
        {
            if (fileInfo.SPFile == null)
            {
                using (SPSite spSite = new SPSite(fileInfo.SiteId))
                {
                    using (SPWeb spWeb = spSite.OpenWeb(fileInfo.WebId))
                    {
                        fileInfo.SPFile = spWeb.GetFile(fileInfo.FileId);
                        return fileInfo.SPFile.TimeLastModified;
                    }
                }
            }
            return new DateTime();
        }