简体   繁体   English

w3wp 应用程序池 IIS 7 的高内存使用率

[英]High memory usage with w3wp application pool IIS 7

I have a website application running in it's own application pool on IIS 7.0.我有一个网站应用程序在 IIS 7.0 上运行在它自己的应用程序池中。 The application is an ASP.NET MVC 3 website.该应用程序是一个 ASP.NET MVC 3 网站。

I have noticed the memory usage for this applications corresponding w3wp IIS worker service is quite high ( 800 MB, with some fluctuation ).我注意到这个应用程序对应的 w3wp IIS 工作服务的内存使用量相当高(800 MB,有一些波动)。

I am trying to diagnose the problem and have tried the following:我正在尝试诊断问题并尝试了以下方法:

I have disabled output page caching for the website at IIS level and then recycled the application pool.我在 IIS 级别禁用了网站的输出页面缓存,然后回收了应用程序池。 This causes the w3wp process to restart.这会导致 w3wp 进程重新启动。 The memory usage for this process then slowly creeps up to around 800 MB, it takes around 30 seconds to do so.此过程的内存使用量会慢慢增加到大约 800 MB,大约需要 30 秒。 There are no page requests being handled at this time.目前没有正在处理的页面请求。 When I restart the website from IIS the memory size of the process does not alter.当我从 IIS 重新启动网站时,进程的内存大小不会改变。

I have tried running a debug copy of the application from VS 2010, there are no problems with memory usage.我尝试从 VS 2010 运行应用程序的调试副本,内存使用没有问题。

Some ideas I have/questions are:我的一些想法/问题是:

Is this problem related to the websites code?这个问题与网站代码有关吗? - Given that the memory rockets before any page requests have been sent/handled, I would assume this is NOT a code problem? - 考虑到在发送/处理任何页面请求之前内存会飙升,我认为这不是代码问题?

The application built in MVC has no handling of caching written into it. MVC 中内置的应用程序没有写入缓存处理。

The website uses real-time displaying of data, it uses ajax requests periodically, and is generally left 'open' for long periods of time.该网站使用实时数据显示,它定期使用 ajax 请求,并且通常长时间处于“开放”状态。

Why does the memory usage rocket up after the application is recycled and no user requests are being sent?为什么在应用程序被回收并且没有用户请求被发送后内存使用量会激增? Is this because it is loading old cache information into it's memory from disk?这是因为它正在将旧的缓存信息从磁盘加载到它的内存中吗?

The application does NOT crash, I'm just concerned about the memory usage, it is not that big of a website...应用程序不会崩溃,我只关心内存使用情况,它不是一个大网站...

Any ideas/help with getting to the bottom of this problem would be appreciated.任何有关解决此问题的想法/帮助将不胜感激。

The best thing to do if you can afford to use a debugger is install the Windows Debugging Tools and use something like WinDbg and SOS.dll to figure out exactly what is it in memory.如果您负担得起使用调试器的费用,那么最好的办法是安装Windows 调试工具并使用诸如 WinDbg 和 SOS.dll 之类的东西来准确找出它在内存中的内容。

once you've installed the tools then you can:安装工具后,您可以:

  1. Launch Windbg.exe running elevated (as Administrator)启动 Windbg.exe 运行提升(以管理员身份)
  2. Use "File->Attach To Process" and choose w3wp.exe for the app you are trying to figure out.使用“File->Attach To Process”并为您要查找的应用程序选择 w3wp.exe。 If you have many you can use Task Manager and add the command-line column to see the PID or use IIS Manager->Worker Processes to figure it out, and then choose that process in WinDBG.如果你有很多你可以使用任务管理器并添加命令行列来查看PID或使用IIS Manager->Worker Processes来计算它,然后在WinDBG中选择该进程。
  3. run:跑步:
  4. .loadby sos clr .loadby sos clr
  5. !dumpheap -stat !dumpheap -stat

At that point you should be able to see all types sorted by the most memory consumption so you can start with the ones at the bottom.那时,您应该能够看到按内存消耗最多的所有类型排序,这样您就可以从底部的类型开始。 (I would recommend exclude Strings, and Object since those are usually a side-effect and not the cause). (我建议排除字符串和对象,因为它们通常是副作用而不是原因)。 Use "!dumpheap -type type-here" to find the instances and use !gcroot for those to figure out why they are in memory, maybe due to a static field, or an event handler leaked, WCF channels not disposed, or things like that are common sources.使用“!dumpheap -type type-here”查找实例并使用 !gcroot 找出它们为什么在内存中,可能是由于静态字段,或事件处理程序泄漏,WCF 通道未处理,或诸如此类那是常见的来源。

I just looked my server and my pools use 900-1000 MB Virtual size Memory, and 380 MB Working set.我只是查看了我的服务器,我的池使用了 900-1000 MB 虚拟大小内存和 380 MB 工作集。 My sites run smooth with out problem for some years now, and I have checked the sites from all sides.我的网站运行顺畅,没有出现问题已有几年了,我已经检查了各个方面的网站。 My pool never recycles and the server runs until the next update continuously with 40% stable free physical memory.我的池从不回收,服务器一直运行到下一次更新,并且有 40% 的稳定可用物理内存。

If your memory is not continuously growing, then this memory is the code plus the data that you set as static, const, the string, and the possible cache, inside your application.如果您的内存没有持续增长,那么此内存就是代码加上您在应用程序中设置为静态、常量、字符串和可能的缓存的数据。

You can use process explorer to see the working and the virtual size memory.您可以使用进程资源管理器查看工作和虚拟大小内存。

You can also think to run a profile against your code to see if you have any "memory leak" or other issue.您还可以考虑针对您的代码运行配置文件,以查看您是否有任何“内存泄漏”或其他问题。 Find one from google: https://www.google.com/search?hl=en&q=asp.net+memory+profiler .从谷歌找一个: https : //www.google.com/search?hl= en & q = asp.net+memory+ profiler

It probably doesn't apply here but thought I would throw it in for good measure.它可能不适用于这里,但我认为我会很好地将其投入使用。 Recently I had a problem where my memory would go right up and max out when it really could of cleaned up 80% of it.最近我遇到了一个问题,当它真的可以清理 80% 时,我的内存会立即上升并最大化。 Problem: It thought it about 2 more gig than it actually did so the GC was quite lazy.问题:它认为它比实际多 2 个演出,因此 GC 非常懒惰。 (It was due to a VM ware bug -windows was reporting 8 Gig but physically there was only 6.4). (这是由于 VM ware 错误-windows 报告了 8 Gig,但实际只有 6.4)。 See blog.见博客。 http://www.worthalook.net/2014/01/give-back-memory/ http://www.worthalook.net/2014/01/give-back-memory/

Something that might help: if you "rewrite" (open/save) the web.config , then your application will reset, you should monitor the memory usage from that point.可能有帮助的事情:如果您“重写”(打开/保存) web.config ,那么您的应用程序将重置,您应该从那时起监视内存使用情况。 If it keeps growing during usage, this could mean memory leak or insane caching.如果它在使用过程中不断增长,这可能意味着内存泄漏或疯狂缓存。 You might be able to identify which actions on your site lead to memory increase.您或许能够确定您网站上的哪些操作会导致内存增加。 During a long time the memory usage of an application should be stable.在很长一段时间内,应用程序的内存使用应该是稳定的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM