Prevent the FubuMVC.Core.Packaging.VirtualPaths.FileSystemVirtualPathProvider from loading

25 views
Skip to first unread message

hcoverlambda

unread,
Feb 24, 2015, 8:56:06 PM2/24/15
to fubumv...@googlegroups.com
So we've had an intermittent problem with the FubuMVC.Core.Packaging.VirtualPaths.FileSystemVirtualPathProvider:

System.OutOfMemoryExceptionException of type 'System.OutOfMemoryException' was thrown. 
at System.Collections.Generic.Dictionary`2.Resize(Int32 newSize, Boolean forceNewHashCodes) 
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) 
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value) 
at FubuCore.Util.Cache`2.Fill(TKey key, Func`2 onMissing) in c:\BuildAgent\work\4dafc5966c0aefb4\src\FubuCore\Util\Cache.cs:line 132 
at FubuMVC.Core.Packaging.VirtualPaths.FileSystemVirtualPathProvider.FileExists(String virtualPath) in c:\BuildAgent\work\ae412c8ad89b884b\src\FubuMVC.Core\Packaging\VirtualPaths\FileSystemVirtualPathProvider.cs:line 46 
at System.Web.WebPages.FileExistenceCache.FileExists(String virtualPath) 
at System.Web.WebPages.VirtualPathFactoryManager.PageExistsInVPP(String virtualPath, Boolean useCache) 
at System.Web.WebPages.VirtualPathFactoryManager.PageExists(String virtualPath, Boolean useCache) 
at System.Web.WebPages.WebPageRoute.FileExists(String virtualPath, VirtualPathFactoryManager virtualPathFactoryManager) 
at System.Web.WebPages.WebPageRoute.MatchRequest(String pathValue, IEnumerable`1 supportedExtensions, VirtualPathFactoryManager virtualPathFactoryManager) 
at System.Web.WebPages.WebPageRoute.DoPostResolveRequestCache(HttpContextBase context) 
at System.Web.WebPages.WebPageHttpModule.OnApplicationPostResolveRequestCache(Object sender, EventArgs e) 
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

We get a ton of hits that have a unique url param (e.g. https://www.yada.com/yada/ZjecaePh57QK_24sFvk1tQ2/yada). This path provider caches the url lookups in a dictionary and we exceed the the max number of entries (about 6 million) and it blows up. I've been digging through the fubu source trying to figure out how I can prevent this provider from being activated but have had no luck. I have a non caching version that I've wired up but can't seem to figure out a way to get rid of this one. Any ideas?

hcoverlambda

unread,
Feb 25, 2015, 10:09:01 AM2/25/15
to fubumv...@googlegroups.com
Well it looks like that path provider is not wired through the ioc container. So here is the quick and dirty solution in case anyone runs into this:

public static void RemoveActivator<T>(this IPackageFacility facility) where T : IActivator
{
    var action = (IList<Action<PackagingRuntimeGraph>>)facility.GetType().GetField("_configurableActions",
        BindingFlags.NonPublic | BindingFlags.Instance).GetValue(facility);
    action.Add(graph =>
    {
        var activators = (IList<IActivator>)graph.GetType().GetField("_activators",
            BindingFlags.NonPublic | BindingFlags.Instance).GetValue(graph);
        var activator = activators.OfType<T>().FirstOrDefault();
        if (activator != null) activators.Remove(activator);
    });
}

public class Bootstrap
{
    public static void Start()
    {
        FubuApplication.
            ...
            .Packages(x =>
            {
                x.RemoveActivator<VirtualPathProviderActivator>();
                x.Activator(new NonCachingVirtualPathProviderActivator());
            })
            .Bootstrap();
    }
}
Reply all
Reply to author
Forward
0 new messages