抛出了类型'System.OutOfMemoryException'的异常。

时间:2013-08-26 06:55:03

标签: asp.net vb.net out-of-memory

我遇到了以下问题

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +567
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +192
   System.Reflection.Assembly.Load(String assemblyString) +35
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +123

[ConfigurationErrorsException: Exception of type 'System.OutOfMemoryException' was thrown.]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +11569328
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +485
   System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +79
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +337
   System.Web.Compilation.BuildManager.CallPreStartInitMethods() +280
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1167

[HttpException (0x80004005): Exception of type 'System.OutOfMemoryException' was thrown.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11702064
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4870277

我没有更改代码?这是什么意思,因为我看到没有更多关于错误的声明

5 个答案:

答案 0 :(得分:31)

当某些进程(如将大量数据加载到内存流和系统内存中)无法存储大量数据时,通常会发生此问题。尝试通过命令

清除临时文件夹
  

开始 - >跑 - > %TEMP%

答案 1 :(得分:12)

在调试模式下运行

在开发和调试应用程序时,通常会将web.config文件中的debug属性设置为true,并以调试模式编译DLL。但是,在将应用程序部署到测试或生产之前,应该在发布模式下编译组件并将debug属性设置为false。

在调试模式下运行时,ASP.NET在许多级别上的工作方式不同。事实上,当您在调试模式下运行时,GC将允许您的对象保持更长时间(直到示波器结束),因此在调试模式下运行时,您将始终看到更高的内存使用量。

在调试模式下运行的另一个经常未实现的副作用是通过webresource.axd和scriptresource.axd处理程序提供的客户端脚本不会被缓存。这意味着每个客户端请求都必须下载任何脚本(例如ASP.NET AJAX脚本),而不是利用客户端缓存。这可能会导致性能大幅下降。

来源:http://blogs.iis.net/webtopics/archive/2009/05/22/troubleshooting-system-outofmemoryexceptions-in-asp-net.aspx

答案 2 :(得分:11)

要尝试的另一件事是

工具 - >选项 - >搜索 IIS - > tick 将64位版本的IIS Express用于网站和项目

Use the 64 bit version of IIS Express for web sites and projects screenshot

答案 3 :(得分:5)

我刚刚重启了Visual Studio并完成了IISRESET,解决了这个问题。

答案 4 :(得分:4)

如果您正在使用IIS Express,请在任务栏通知区域的IIS Express中选择{ counts = 1; "m_drycleaning_price" = 12; "m_id" = 3; "m_imagename" = d; "m_iron_price" = 16; "m_name" = "Coat(Man)"; "m_wash_price" = 14; "m_washiron_price" = 13; total = 12; } AppDelegate *myAppDelegate = [[UIApplication sharedApplication] delegate]; [myAppDelegate.arrayCounts addObject:dictValues]; myAppDelegate.arrayCounts[indexPath.row][@"counts"] = [NSString stringWithFormat:@"%d",(int)value]; myAppDelegate.arrayCounts[indexPath.row][@"total"] = [NSString stringWithFormat:@"%d",(int)y]; - (IBAction)placeorder:(id)sender { NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; [userDefaults setObject:global.filteredArray forKey:@"def_orderarraylist"]; NSMutableArray *qualifiersArray = [NSMutableArray arrayWithArray:[userDefaults objectForKey:@"def_orderarraylist"]]; NSLog(@"qualifier array=%@",qualifiersArray); [userDefaults synchronize]; } ,然后选择Show All Application

现在重新运行您的应用程序。