aspnet / AspNetWebStack

ASP.NET MVC 5.x, Web API 2.x, and Web Pages 3.x (not ASP.NET Core)
Other
858 stars 354 forks source link

UrlHelper.Action high memory allocations #382

Closed aaronhudon closed 1 year ago

aaronhudon commented 1 year ago

Using nuget 5.2.7

I know this code base is getting long in the tooth...but so am I, and here we are.

I have enabled Optimization Insights on a fairly high-traffic SaaS system with the above mentioned version. The largest pain point I am seeing from Optimization Insights is the condition that UrlHelper.Action is chewing up memory.

Short of upgrading (which will be no small feat), or coming up with my own routing mechanism....any ideas, any hope?

Output from Opt Insights:

system.web!System.Web.Routing.ParsedRoute.Bind(class System.Web.Routing.RouteValueDictionary,class System.Web.Routing.RouteValueDictionary,class System.Web.Routing.RouteValueDictionary,class System.Web.Routing.RouteValueDictionary)
system.web!System.Web.Routing.Route.GetVirtualPath(class System.Web.Routing.RequestContext,class System.Web.Routing.RouteValueDictionary)
system.web!System.Web.Routing.RouteCollection.GetVirtualPath(class System.Web.Routing.RequestContext,class System.Web.Routing.RouteValueDictionary)
system.web.mvc!System.Web.Mvc.RouteCollectionExtensions.GetVirtualPathForArea(class System.Web.Routing.RouteCollection,class System.Web.Routing.RequestContext,class System.String,class System.Web.Routing.RouteValueDictionary,bool&)
system.web.mvc!System.Web.Mvc.UrlHelper.GenerateUrl(class System.String,class System.String,class System.String,class System.Web.Routing.RouteValueDictionary,class System.Web.Routing.RouteCollection,class System.Web.Routing.RequestContext,bool)
system.web.mvc!System.Web.Mvc.UrlHelper.Action(class System.String,class System.Object)
app_web_knposs0j!ASP._Page_Views_******_cshtml.Execute()
system.web.webpages!System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
system.web.mvc!System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
system.web.webpages!System.Web.WebPages.StartPage.ExecutePageHierarchy()
system.web.webpages!System.Web.WebPages.WebPageBase.ExecutePageHierarchy(class System.Web.WebPages.WebPageContext,class System.IO.TextWriter,class System.Web.WebPages.WebPageRenderingBase)
system.web.mvc!System.Web.Mvc.ViewResultBase.ExecuteResult(class System.Web.Mvc.ControllerContext)
mkArtakMSFT commented 1 year ago

Thank you for filing this issue. In order for us to investigate this issue, please provide a minimalistic repro project that illustrates the problem.

aaronhudon commented 1 year ago

@mkArtakMSFT to reproduce this, you will need a production-level ASP MVC5 system running in Azure, and enable Optimization Insights.

Make sure your system has a decent amount of traffic, and the pages it services uses @Url.Action numerous times in a Razor page.

mkArtakMSFT commented 1 year ago

Without a reliable repro we won't be able to investigate this further. Also, we're focusing only on critical bugs and security fixes on this repo. We won't be able to address issues which are "nice to have". I refer to it this way, because that code hasn't been updated for many years and we haven't seen major concerns with it.