CLR内存不足异常 [英] CLR out Of Memory Exceptions

查看:143
本文介绍了CLR内存不足异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经看到了很多内存不足异常的,我们似乎无法诊断发生了什么。这似乎是这种情况发生,将秒杀300兆的内存使用量超过演出在几个敏的母校的问题。现在,这是一个IIS应用程序,并在单独的线程池中运行3应用程序域。

We are getting a lot of out of memory exceptions and we cant seem to diagnose what is happening. It seems to be an issue that happens that will spike memory usage from 300 megs to over a Gig in a mater of a few Min. Now this is an IIS app and has 3 app domains running in separate thread pools.

我们希望在内存异常即将发生的记录。因此,我们可以试图找到一种模式。我的问题是:什么是做到这一点的最好方法是什么?有没有一种方法来查询内存使用一次分钟,看看它是多么高,发送报警邮件。或者,也许写一个应用程序,将监视CLR的内存使用情况?一个想法或一个方向是更然后欢迎。

We want to record when the Memory exceptions are about to happen. So we can attempt to find a pattern. My question is: What is the best way to do this? Is there a way to Query the Memory usage once a min to see how high it is and send an alert email. Or maybe write an app that will monitor the CLR's memory usage? an ideas or a direction are more then welcome.

修改

我使用的性能监视器,但除非我正在看它的过程是没有多大用处的。我只能看到什么是时候。我也用红门记忆档案的工具,这是由路真棒,只有我似乎无法打APON是导致异常的网页或程序。

I am using Perfmon but unless I am watching the process it is not that useful. I can only see what is was and when. I have also used the Red Gate Memory Profile tool, which is awesome by the way, only I cannot seem to hit apon the page or process that is causing the exception.

推荐答案

在服务器上安装ADPlus的(在的的Windows调试工具)。当你开始使用观测异常的高内存使用捕获内存转储:

Install ADPlus on your server (it's part of the Windows Debugging Tools). When you start observing unusually high memory usage capture a memory dump using:

adplus -hang -p <PID> -quiet -o <dump file folder path>



< PID> 是进程ID的工作进程,你可以从 tasklist.exe 得到。

<PID> is the process ID of the worker process which you can get from tasklist.exe.

如果你不总是围绕这个时出现问题,那么你可以自动化捕获使用内存转储 DebugDiag资料

If you're not always around when this issue occurs then you could automate capturing a memory dump using DebugDiag:


  1. 使用DebugDiag资料泄漏在跟踪模式触发一个进程转储时,无论你的私人或虚拟内存使用达到一定的阈值。尽管如此,我并不总是发现这个可靠的。

  1. Use DebugDiag in leak tracking mode to trigger a process dump when either your Private or Virtual memory use reaches a certain threshold. That said, I've not always found this reliable.

使用DebugDiag资料在崩溃模式下拍摄时CLR抛出异常转储。您可以使用高级设置来配置DebugDiag资料在遇到类型的CLR例外的System.OutOfMemoryException 来产生一个完全内存转储。这是更可靠的,肯定会被触发。仅使用高级设置 - >例外,请勿触摸未配置的第一次机会异常,应保留这一切都不设置

Use DebugDiag in Crash Mode to capture a dump whenever CLR exceptions are thrown. You can used the Advanced Settings to configure DebugDiag to produce a full memory dump upon encountering a CLR exception of type System.OutOfMemoryException. This is more reliable and will definitely trigger. Only use Advanced Settings -> Exceptions, don't touch the Unconfigured First Chance Exceptions, leave this setting at None.

一旦你有你的内存转储火起来的WinDBG,加载转储文件并加载SOS,并开始戳约

Once you have your memory dump fire up WinDBG, load the dump file and load up SOS and start poking about.

苔丝Ferrandez的的博客是一个伟大的.NET调试的资源,她有足够的了解如何跟踪内存泄漏的文章和实验室:

Tess Ferrandez's blog is a great .NET debugging resource and she has plenty of articles and labs about how to track down memory leaks:

如果它坏了,解决它,你应该 - 内存问题的文章

NET调试演示实验6:_Memory泄漏结果
NET调试演示实验6:_Memory泄漏 - 回顾结果
NET调试演示实验7:内存泄漏结果
NET调试演示实验室7:内存泄漏 - 审查

PerfMon计数器是有用的,可以用来确认您有内存泄漏,但他们不告诉整个故事。的WinDBG和SOS是你需要使用找出正在使用你的记忆是哪里的工具。

PerfMon counters are useful and can be used to confirm that you have a memory leak, but they don't tell the whole story. WinDBG and SOS are the tools you need to use to find out where your memory is being used.

这篇关于CLR内存不足异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆