我(巨)应用程序抛出一个OutOfMemoryException,现在该怎么办?抛出、应用程序、现在、OutOfMemoryException

2023-09-03 16:35:26 作者:南城以南ソ温暖如初

这是目前为止最复杂的软件,我已经建立,现在它似乎是耗尽内存在一些点。我没有做广泛的测试还没有,因为我有点失去了我应该怎么手头解决这个问题。

This is by far the most complex software I've built and now it seems to be running out of memory at some point. I haven't done extensive testing yet, because I'm a bit lost how I should approach the problem at hand.

HandleCount: 277
NonpagedSystemMemorySize: 48136
PagedMemorySize: 1898590208
PagedSystemMemorySize: 189036
PeakPagedMemorySize: 1938321408
VirtualMemorySize: 2016473088
PeakVirtualMemory: 2053062656
WorkingSet: 177774592
PeakWorkingSet: 883834880
PrivateMemorySize: 1898590208
PriviligedProcessorTime: 00:00:15.8593750
UserProcessorTime: 00:00:01.6562500
TotalProcessorTime: 00:00:17.5156250
GDI Objects: 30
User Objects: 27

我有一个自动全局异常捕捉器,以在异常收集上述信息(使用的System.Diagnostics.Process) - 除信息一起,记录和屏幕截图 - 和电子邮件,我的一切

I have an automated global exception catcher that upon exception gathers the above information (using System.Diagnostics.Process) - along with the exception information, log and a screen shot - and e-mails me everything.

这一直很好,因为我已经能够堵塞基础上,通过电子邮件发送的信息的错误。这是,到现在为止。该软件是行数以万计,并使用托管和非托管资源。

This has been working nicely as I've been able to plug bugs based on the e-mailed information. This is, up until now. The software is tens of thousands of lines and uses managed and unmanaged resources.

我可以开始经历code,一行行,但有些我是如何得到一个感觉,这可能不是最好的办法,试图推断出内存积聚的问题。

I could start going through the code, line by line, but some how I get a feeling this might not be the best approach to try to deduce the memory build-up problem.

正如我以前从来没有做过这样的分析,建议你将如何处理这个样的问题?

As I've never done this kind of analysis before, how would you suggest to approach this kind of a problem?

推荐答案

我们提供了一种工具。

http://msdn.microsoft.com/en-us/library/ ms979205.aspx

CLR Profiler可以看   进程的托管堆和   调查的行为   垃圾收集器。使用各种   意见的工具,你可以得到   有关的有用信息   执行,分配和内存   您的应用程序消耗。

CLR Profiler enables you to look at the managed heap of a process and investigate the behavior of the garbage collector. Using the various views in the tool, you can obtain useful information about the execution, allocation, and memory consumption of your application.

使用CLR分析器,你可以   确定code表示分配太多   内存,导致过多的垃圾   收藏,并持有到内存   太久了。

Using CLR Profiler, you can identify code that allocates too much memory, causes too many garbage collections, and holds on to memory for too long.