工作进程回收,因为它达到了虚拟内存限制

发布于 2024-07-09 20:58:56 字数 799 浏览 5 评论 0 原文

我们为客户托管一个相当大的(自行编写的)ASP.NET 网站。 它由一个 Web 服务、一个网站和一个图像服务网站组成,这三个网站都位于各自的虚拟目录中。 这三个虚拟目录位于一个应用程序池中。 该池的内存限制(最大虚拟内存和最大已用内存)均设置为 500 MB。

然而,应用程序池会遭受多次回收,即使一次只有一个用户。 事件日志消息显示:

进程 ID 为“xxxx”的工作进程为应用程序池“xxxx”提供服务,已请求回收,因为它达到了其虚拟内存限制。

但是,使用 Process Explorer 观察工作进程没有显示任何支持此消息的信息。 我应该观察哪些计数器来观察实际上受这两种设置限制的内存?

更新 1

在任务管理器中观察该进程,显示“内存使用情况”和“虚拟机大小”约为 100 MB,但该进程仍被回收并显示上述消息。 服务器上有 5 GB 可用物理内存...

更新 2

虽然网站相当大,但问题集中在应用程序的一小部分。 它执行查询(使用 Oracle)并将结果绑定到 gridview 和 Repeater Webcontrol。 结果由简短描述和图标(通过图像服务网站加载)组成。 如果我依次执行 10 个搜索操作,每个搜索操作给出 9 个结果,则工作进程会显示内存使用情况和大约 100 MB 的虚拟机大小并回收...

更新 3 切换图像服务网站的使用并不会产生更好的结果。 所以我认为可以公平地说问题是别的问题。

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.

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.

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?

Update 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...

Update 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...

Update 3
Switching 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

还给你自由 2024-07-16 20:58:56

就像观察一样...
如果您的“图像服务”站点碰巧执行任何内联图像处理/生成,那么您可以通过不在任何一次性资源上调用 Dispose() 来快速吞噬内存 - 特别是那些包装本机功能的资源。这

不是对您问题的直接答案,但可能有助于调查导致内存使用猖獗的根本问题。

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...

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.

心安伴我暖 2024-07-16 20:58:56

当我们将内存大小从 4Gb 升级到 8Gb(讽刺的是)时,我在虚拟机上遇到了同样的问题。 我发现这个博客解释了我们可以在 64 位系统上使用“私有内存限制”,但不能使用“虚拟内存限制”,因为:“如果你在 64 位平台上(我也是),ASP.NET 应用程序会积极保留虚拟内存” 。

http://blog. walteralmeida.com/2011/07/iis7-private-memory-limit-versus-virtual-memory-limit.html

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".

http://blog.walteralmeida.com/2011/07/iis7-private-memory-limit-versus-virtual-memory-limit.html

甜中书 2024-07-16 20:58:56

我决定配置 IIS,以便服务器上的托管应用程序不会因内存使用量过高且不受控制而导致计算机停机。 我确实遇到过这样的情况:我的应用程序开始无限制地消耗内存,快速使用所有可用内存并使服务器无法使用......

为此,我将我的应用程序池的私有内存限制和虚拟内存设置为 500M0以确保有缺陷的应用程序不会导致机器瘫痪。 事实上,如果私有内存限制或虚拟内存高于 500Mo,那么 AppPool 将自动回收,有缺陷的进程将被终止,并释放内存。

然而,执行此操作后,我遇到了以下问题:我的 AppPools 确实回收得太频繁,几乎在每个请求中都进行回收,即使内存使用量很低!

经过一些研究,我找到了问题的原因:

如果您使用的是 64 位平台(我也是),ASP.NET 应用程序会积极保留虚拟内存。 同样重要的是要了解,在 64 位平台上,保留大部分虚拟内存对性能的影响为零。 因此,即使进程的私有内存使用率较低,虚拟内存限制也会很快达到! 这使得 AppPool 虚拟内存限制在 64 位计算机上毫无用处...

因此解决方案是:

不要设置任何 AppPool 虚拟内存限制,只需设置 AppPool 物理内存限制。

希望这可以帮助其他人!

I decided to configure IIS so that hosted applications on my server would not bring the machine down because of high and uncontrolled memory usage. It happened to me indeed that one my applications started to consume memory up to no limit, quickly using all the memory available and rendering the server unusable...

To that purpose I did set the Private Memory Limit and Virtual Memory of my AppPools to 500M0 to make sure a flawed application won't bring the machine down. Indeed if either the Private Memory Limit or Virtual Memory would go higher than 500Mo then the AppPool would automatically be recycled, the flawed process killed, and memory freed.

However, following this action, I had the following problem: my AppPools did recycle too often, almost at every single request, even though the memory usage was low!

After some research I found the cause of my trouble:

If you are on a 64bit platform (and I am), ASP.NET app's aggressively reserve virtual memory. It's also important to understand that on a 64bit platform, reserving large portions of virtual memory has zero performance impact. Therefore, the Virtual Memory Limit is reached very quickly, even thought the process is making low usage of private memory! This renders the AppPool Virtual Memory Limit useless on 64bit machines...

Therefore solution is:

Do not set any AppPool Virtual Memory Limit, just set the AppPool Physical Memory Limit.

Hope this can help others!

白鸥掠海 2024-07-16 20:58:56

这可能是有用的链接:

http://blogs.msdn.com/tom/archive/2008/06/25/asp-net-tips-finding-what-is-take-up-memory.aspx

(以及之前的帖子,解释了他正在做的事情的更多背景)

This might be useful link:

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)

请恋爱 2024-07-16 20:58:56

尝试使用 Windows 任务管理器。 在进程选项卡上,转到“视图”菜单并选择“选择列”。 选择“虚拟内存大小”列,然后观察 asp.net 工作进程的值。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文