我们已将各种站点更新到 MCV4 版本,同时我们利用了使用 dll System.Web.Optimization 创建 Bundle 的能力。一切正常。
但是,我们有以下问题:当调用 javascript 时,应用程序的 bundle分配了大约 50 MB RAM,而没有释放它。捆绑包中包含的 javascript 总共约为 2 Mb。
注意:我们在全局 asax 中创建 Bundles,事件“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")
%>
有没有其他人遇到过这个问题?有什么建议可以减少这种内存消耗吗?