Asp.net Mvc site running out of memory

可紊 提交于 2019-12-24 04:47:06

问题


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.


回答1:


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




回答2:


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.




回答3:


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)



来源:https://stackoverflow.com/questions/6758975/asp-net-mvc-site-running-out-of-memory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!