我们已经将各种站点更新为MCV4版本,同时我们利用了使用dll System.Web.Optimization创建Bundle的功能.一切都奏效
但是,我们有以下问题:
当javascript被调用时,应用程序的bundle会分配约50 MB的RAM,而不会释放它.包含在包中的JavaScript总共约为2Mb.
注意:
我们在全球asax中创建Bundle,事件“Application_Start”
protected virtual void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterBundles(BundleTable.Bundles); RegisterRoutes(RouteTable.Routes); } protected virtual void RegisterBundles(BundleCollection bundles) { bundles.Add(new StyleBundle("~/content/all.css").Include( "~/content/site.css" )); bundles.Add(new StyleBundle("~/content/themes/base/base.all.css").Include( "~/Content/themes/base/jquery-ui-1.8.23.custom.css","~/content/themes/base/kendo.common.css","~/content/themes/base/kendo.totalcom.css","~/Content/themes/base/jquery.contextmenu.css","~/content/themes/base/tipsy.css","~/content/themes/base/jquery.ibutton.css" )); bundles.Add(new ScriptBundle("~/Scripts/all.js").Include( "~/Scripts/jquery-1.8.2.js","~/Scripts/modernizr-1.7.js","~/Scripts/jquery-ui-1.8.22.custom.js","~/Scripts/jquery.validate.js","~/Scripts/jquery.validate.unobtrusive.js","~/Scripts/jquery.unobtrusive-ajax.js","~/Scripts/conditional-validation.js","~/Scripts/fileuploader.js","~/Content/tiny_mce/jquery.tinymce.js","~/Scripts/kendo.all.js","~/Scripts/kendo.aspnetmvc.js","~/Scripts/jquery.contextmenu.js","~/Scripts/jquery.tipsy.js","~/Scripts/jquery.checkradio.js","~/Scripts/jquery.Metadata.js","~/Scripts/jquery.ibutton.js","~/Scripts/jquery.easing.js","~/Scripts/functions.js","~/Scripts/Erp.js","~/Scripts/Cms.js" )); }
捆绑包在主页中调用
<%: Styles.Render("~/Content/all.css") %> <%: Styles.Render("~/content/themes/base/base.all.css") %> <%: Scripts.Render("~/Scripts/all.js") %>
编辑:
当执行以下行时,使用额外的50mb内存
<%: Scripts.Render("~/Scripts/all.js") %>
有其他人遇到这个问题吗?有什么建议来减少这种内存消耗?
解决方法
当我提供kendo.all.js(这是一个惊人的5MB;最小化的版本是2MB左右)时,我最近不得不处理捆绑包,为我的IIS进程添加了200MB的内存,这是可笑的.我打算将这个kendo文件分解成几个包,并消除不想要的控件,但是我以后想处理.
在我的情况下,我从供应商那里收集了资产的未最终版本和最小化版本. I don’t need Bundles to minify anything.所有我需要做的是在debug =“true”时发出直接链接到未定义的脚本,并在debug =“false”时发出连接到但预先设置的脚本的链接.
在我的BundleConfig.cs中,我一直在为我的供应商文件使用一个ScriptBundle,该文件将尝试减少,从而产生了我已经提到过的那个帽子.使用简单的旧软件包给我我需要的功能,而不尝试缩小,并节省了大量的内存. SOD关闭,ScriptBundle!