.net 工作进程因达到其虚拟内存限制而回收
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/381088/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Worker process recycles because it reached its virtual memory limit
提问by Michiel Overeem
We host a rather large (self written) ASP.NET website for our customers. It consists of a web service, a web site and a image serving web site, all three in their own virtual directory. The three virtual directories are together in one application pool. The pool has both memory limits (maximum virtual memory and maximum used memory) set to 500 megabytes.
我们为我们的客户托管了一个相当大的(自己编写的)ASP.NET 网站。它由一个网络服务、一个网站和一个图像服务网站组成,这三者都在它们自己的虚拟目录中。这三个虚拟目录一起在一个应用程序池中。该池的内存限制(最大虚拟内存和最大已用内存)均设置为 500 兆字节。
However, the application pool suffers many recycles, even with only one user at a time. The eventlog message says:
但是,即使一次只有一个用户,应用程序池也会遭受多次回收。事件日志消息说:
A worker process with process id of 'xxxx' serving application pool 'xxxx' has requested a recycle because it reached its virtual memory limit.
服务应用程序池“xxxx”的进程 ID 为“xxxx”的工作进程已请求回收,因为它已达到其虚拟内存限制。
However, observing the worker process with Process Explorer shows nothing that supports this message. Which counters should I watch to observe the memory that is in fact limited by both settings?
但是,使用 Process Explorer 观察工作进程没有显示任何支持此消息的内容。我应该观察哪些计数器来观察实际上受两种设置限制的内存?
Update 1
更新 1
Observing the process in Task Manager shows a 'mem usage' and 'vm size' of around 100 MB, still the process is recycled with the above message. 5 GB physical memory available on the server...
观察任务管理器中的进程显示大约 100 MB 的“内存使用情况”和“虚拟机大小”,但该进程仍然被上述消息回收。服务器上可用的 5 GB 物理内存...
Update 2
更新 2
Although the web site is rather large, the problem concentrates in a small portion of the application. It executes a query (using Oracle) and binds the results to a gridview and repeater webcontrol. The results consists of a short description and an icon (loaded through the image serving web site). If I execute 10 search actions after each other, each giving 9 results, the work process shows mem usage and vm size of around 100 MB and recycles...
虽然网站很大,但问题集中在应用程序的一小部分。它执行查询(使用 Oracle)并将结果绑定到 gridview 和转发器 webcontrol。结果由简短说明和图标(通过图像服务网站加载)组成。如果我依次执行 10 个搜索操作,每个操作给出 9 个结果,则工作过程显示内存使用情况和 vm 大小约为 100 MB 并回收......
Update 3Switching of the usage of the image serving web site does not result in better results. So I think it is fair to say that the problem is something else.
更新 3切换图像服务网站的使用不会产生更好的结果。所以我认为可以公平地说问题是其他问题。
回答by Andrew Rollings
Just as an observation...
If your "image serving" site happens to do any inline image processing/generation, you can quickly swallow up memory by not calling Dispose()on any disposable resources - particularly those that are wrapping native functionality...
只是作为观察...如果您的“图像服务”站点碰巧进行任何内联图像处理/生成,您可以通过不调用Dispose()任何一次性资源来快速吞噬内存- 特别是那些包装本机功能的资源......
It's not a direct answer to your question, but it might help to look into the underlying problem that is causing the rampant memory use.
这不是您问题的直接答案,但它可能有助于调查导致内存使用猖獗的潜在问题。
回答by Matt Roy
I had the same problem with a Virtual Machine when we upgraded memory size from 4Gb to 8Gb (ironically). I found this blog which explains we can use "private memory limit" but not "virtual memory limit" with 64bit system, because : "If you are on a 64bit platform (and I am), ASP.NET app's aggressively reserve virtual memory".
当我们将内存大小从 4Gb 升级到 8Gb(具有讽刺意味)时,我在虚拟机上遇到了同样的问题。我发现这个博客解释了我们可以在 64 位系统上使用“私有内存限制”而不是“虚拟内存限制”,因为:“如果你在 64 位平台上(我也是),ASP.NET 应用程序会积极保留虚拟内存” .
http://blog.walteralmeida.com/2011/07/iis7-private-memory-limit-versus-virtual-memory-limit.html
http://blog.walteralmeida.com/2011/07/iis7-private-memory-limit-versus-virtual-memory-limit.html
回答by Will Dean
This might be useful link:
这可能是有用的链接:
http://blogs.msdn.com/tom/archive/2008/06/25/asp-net-tips-finding-what-is-taking-up-memory.aspx
http://blogs.msdn.com/tom/archive/2008/06/25/asp-net-tips-finding-what-is-taking-up-memory.aspx
(And earlier posts which explain some more context to what he's doing)
(以及之前的帖子解释了他正在做的事情的更多背景)
回答by DCNYAM
Try using the Windows Task Manager. On the processes tab, go to the View menu and choose Select Columns. Select the Virtual Memory Size column and then observe the value for the asp.net worker process.
尝试使用 Windows 任务管理器。在进程选项卡上,转到查看菜单并选择选择列。选择 Virtual Memory Size 列,然后观察 asp.net 工作进程的值。

