Asp.net Mvc 站点内存不足
我有一个奇怪的场景,网站似乎时不时地随机耗尽内存:它工作了几周,然后突然一切都抛出内存不足异常,并且一直保持这种状态,直到服务器重新启动。它可能会在几周或几天后发生。我们无法识别常规模式。
以下是该网站使用的技术内容列表:
- Net Framework 3.5
- 使用 C#
- Mvc 2.0 ,在专用服务器上
- IIS 6.0(无策略限制等) 3 层架构 (ui - bll - dal)
- Automapper 1.1.0.118
- Elmah 1.1
- FluentValidation 2.0
- MvcContrib 2.0.95.0
- MvcSiteMapProvider 3.0.0.1
- 城堡2.5.2
- NHibernate 3.0.0.4
- FluentNHibernate 1.1.0.0
- PdfSharp 1.31.1789.0
- MarkdownSharp
除此之外,该站点还包括(通过 iframe)一些旧的遗留 asp 表单。这些表单与旧版本网站上的表单(完全是 asp)相同,它们有一些问题,但旧网站从未耗尽内存。
我已经检查了常见的内容,例如所有 IDisposable
实现类都在 using
语句内,没有无限循环等。
该网站没有做任何奇怪的事情,它会拉一些来自数据库的数据(如新闻)在提交某些表单后动态生成一些 pdf,允许用户订阅新闻通讯。平常的东西。
我真的很无能,我开发了很多网站,几乎到处都使用了提到的库,但这是我第一次遇到这种问题。
我知道这些信息不足以“找到”问题,但如果有人能想到我可能忽略的东西或任何东西,那将非常受欢迎:)
编辑:一个可能很重要的细节。我们有另一个网站在同一台服务器上运行(用旧的 asp 制作),它运行得很好,而另一个网站则卡住了。所以看起来整个服务器内存并没有耗尽,否则它也无法工作。
I have a weird scenario in which the website seems to randomly run out of memory from time to time: it works for weeks then suddenly everything throws an out of memory exception, and it stays so until the server is rebooted. It may happen after weeks or after days. We weren't able to identify a regular pattern.
Here a list of tech stuff used for this site:
- Net framework 3.5
- Mvc 2.0 with C#
- IIS 6.0 on a dedicated server (no policy restrictions, etc)
- 3 layer architecture (ui - bll - dal)
- Automapper 1.1.0.118
- Elmah 1.1
- FluentValidation 2.0
- MvcContrib 2.0.95.0
- MvcSiteMapProvider 3.0.0.1
- Castle 2.5.2
- NHibernate 3.0.0.4
- FluentNHibernate 1.1.0.0
- PdfSharp 1.31.1789.0
- MarkdownSharp
Other than this, the site includes (via iframes) some old legacy asp forms. Those forms are the same that were on the old version of the site (which was entirely in asp), they have some problems but the old site never ran out of memory.
I've already checked common stuff, like all IDisposable
implementing classes are inside using
statements, no infinite loops, etc.
The site doesn't do anything strange, it pulls some data from the DB like news, generates some pdf on the fly after certain form submissions, allows users to subscribe to a newsletter. The usual stuff.
I'm really clueless, I've developed many sites, used the mentioned libraries almost everywhere, but this is the first time I experience this kind of problem.
I know this information isn't enough to "find" the problem, but if anyone can think of something I might have overlooked, or anything, it will be very welcome :)
EDIT: A detail that might be important. We have another website running on the same server (made with old asp) and it runs just fine, while the other is stuck. So it seems like the overall server memory isn't depleted, otherwise it wouldn't work too.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
安装DebugDiag。当进程超出内存阈值时(例如在 300Mb 时,然后在之后每 100Mb 时),触发它来转储进程。
比较转储文件应该可以让您了解是什么突然占用了所有内存
Install DebugDiag. Trigger it to take dumps of the process as it breaches memory thresholds (say at 300Mb and then at every 100Mb after that).
Comparing the dump files should give you a clue as to what is suddenly occupying all that memory
我想看看 Castle 是如何配置和使用的,您是否使用 castle 来解决控制器依赖项,使用
ControllerBuilder.Current.SetControllerFactory
方法?如果这样做,您还必须记住释放控制器实例。I would have a look at how Castle is configured and used, do you use castle to resolve your controller dependencies, using the
ControllerBuilder.Current.SetControllerFactory
method? If you do, you also have to remember to release the controller instances.如果您在 IIS7/7.5 上托管多应用程序池且负载较高,请尝试更改 gc 模式。
配置文件
[元素](http://msdn.microsoft.com/en-us/library/ms229357.aspx 元素)
If your hosting multi application pool on IIS7/7.5 and high load, try change gc mode.
aspnet.config
[ Element](http://msdn.microsoft.com/en-us/library/ms229357.aspx Element)