Skip to content

Commit 4d1ddf2

Browse files
committed
Fixes issue discussed in #236, random exceptions being thrown when cache expires. Assumption about a potential memory leak because of circular references was incorrect, so there is no need for the SiteMapLoader to call the ISiteMap.Clear() method when the cache expires. Confirmed by adding extra buffer to the SiteMapNode and setting cache duration to 0 that memory is not leaking in this case.
1 parent 76c7986 commit 4d1ddf2

File tree

1 file changed

+0
-12
lines changed

1 file changed

+0
-12
lines changed

src/MvcSiteMapProvider/MvcSiteMapProvider/Loader/SiteMapLoader.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ ISiteMapCreator siteMapCreator
2727
this.siteMapCache = siteMapCache;
2828
this.siteMapCacheKeyGenerator = siteMapCacheKeyGenerator;
2929
this.siteMapCreator = siteMapCreator;
30-
31-
// Attach an event to the cache so when the SiteMap is removed, the Clear() method can be called on it to ensure
32-
// we don't have any circular references that aren't GC'd.
33-
siteMapCache.ItemRemoved += new EventHandler<MicroCacheItemRemovedEventArgs<ISiteMap>>(siteMapCache_ItemRemoved);
34-
3530
}
3631

3732
protected readonly ISiteMapCache siteMapCache;
@@ -72,12 +67,5 @@ public virtual void ReleaseSiteMap(string siteMapCacheKey)
7267
}
7368

7469
#endregion
75-
76-
protected virtual void siteMapCache_ItemRemoved(object sender, MicroCacheItemRemovedEventArgs<ISiteMap> e)
77-
{
78-
// Call clear to remove ISiteMapNode object references from internal collections. This
79-
// will release the circular references and free the memory.
80-
e.Item.Clear();
81-
}
8270
}
8371
}

0 commit comments

Comments
 (0)