简体   繁体   English

如何解决ASP.NET 4.0 Web应用程序中包含ashx处理程序的内存泄漏?

[英]How to resolve Memory Leaks in ASP.NET 4.0 web application contains ashx handlers?

My team has built a web corporate ERP application using ASP.NET 4.0 with Entity Framework,ASHX handlers and web pages(>20). 我的团队使用带有实体框架,ASHX处理程序和网页(> 20)的ASP.NET 4.0构建了一个Web企业ERP应用程序。 The app has been built to accomodate more than 15000 users. 该应用程序可容纳15000多个用户。 But when the application is hosted on Test Enviroment, it throws Bad Gateway error when logged in users exceeds 600. The app contains 3 layer - Front End(ASPX pages), Entity Layer, DataAccess Layer(Classes). 但是,当应用程序托管在Test Enviroment上时,登录的用户超过600时,它将引发Bad Gateway错误。该应用程序包含3层-前端(ASPX页),实体层,数据访问层(类)。

Backend server is SQL Server 2008 R2. 后端服务器是SQL Server 2008 R2。

Testing report says - Connection TimeOuts, Large amount of Memory Leaks and Unmanaged Codes. 测试报告说-连接超时,大量内存泄漏和非托管代码。 We have tried our best to fix memory leaks by disposing the objects and classes,etc. 我们已经尽力通过处理对象和类等来修复内存泄漏。 Application doesn't contain minimal images. 应用程序不包含最少的图像。

But still the problem remains same. 但是问题仍然存在。 Even the server configuration of both Web and DB server is at very high end. 甚至Web和DB服务器的服务器配置都非常高端。 16 CPU and 4 GB RAM. 16个CPU和4 GB RAM。

Can anyone help me out on this? 有人可以帮我吗?

This is going to take you some time and 'digging in' to get a handle on what is causing the issue. 这将花费您一些时间并“深入研究”问题的根源。 Without being there and with access to the code, all we can offer is things to investigate, such as: 在没有代码访问权限的情况下,我们所能提供的只是进行调查,例如:

  • Use performance monitor to get a better picture of what exactly is going on. 使用性能监视器可以更好地了解实际情况。 Do this on both your web and database servers. 在您的Web和数据库服务器上执行此操作。 There are different counters that you want to use for ASP.NET and for SQL Server. 您要为ASP.NET和SQL Server使用不同的计数器。 A search for perfmon.exe, counters, ASP.NET and SQL Server should get you on the right path as to which counters to start with. 搜索perfmon.exe,计数器,ASP.NET和SQL Server应该可以使您正确地开始使用哪个计数器。 Run through various scenarios and examine the numbers in detail: a single user on the site performing various actions, 10 users, 100, etc. 运行各种方案并详细检查数量:站点上执行一项操作的单个用户,10个用户,100个等等。

  • Use SQL Server Profiler to get some insight into what is happening on the database side of things. 使用SQL Server Profiler可以深入了解数据库方面的情况。

  • Use WinDbg - Internet search will get you on the right path - will take some ramp-up if you're not familiar with it, but it's powerful. 使用WinDbg-Internet搜索将使您走上正确的道路-如果您不熟悉它,则会进行一些改进,但它功能强大。

  • I've had great luck in the past using tools like Red Gate ANTS Performance Profiler and Memory Profiler ( Red Gate ). 过去,我曾经使用Red Gate ANTS Performance Profiler和Memory Profiler( Red Gate )之类的工具过得很幸运。 The tools may cost a bit, but they have saved me way more than they cost in being able to quickly identify the 'low hanging fruit' issues. 该工具可能花费了一点,但他们救了我的方式比他们在能够快速识别“低悬的果实”问题的成本。 Disclosure - I'm not affiliated with Red Gate in any way. 披露-我与Red Gate没有任何关系。

  • Do the problems in the test environment start exactly when the users exceed 600, or just generally at some number that varies but is over 600? 测试环境中的问题是在用户超过600时才开始出现,还是只是数量有所不同但超过600时才开始? If the problems always starts at the same number of users, that is a clue to look at what exactly happens when a new user logs in - are you loading a ton of data that isn't necessarily needed, etc. Actually, you should look into this even if the number of users where the problem starts varies, it just has a 'smell' if it always starts at exactly 600... 如果问题总是始于相同数量的用户,那么这是了解新用户登录时究竟发生了什么的线索-您是否正在加载大量不必要的数据,等等。实际上,您应该查看即使问题开始的用户数量有所不同,如果它总是从恰好开始于600,也只是发出“气味”。

  • Are you making heavy use of Session? 您是否在大量使用Session? Where is it stored? 它存储在哪里?

  • What is the required number of simultaneous users you need to support? 您需要支持的并发用户数量是多少? You mention 15,000, are you load balancing across web servers? 您提到15,000,您是否在Web服务器之间实现负载平衡? (This isn't necessarily related to fixing your problem, but something you may need to consider for your architecture) (这不一定与解决问题有关,但是可能需要针对您的体系结构考虑)

  • 4 GB of RAM is not very high end, especially for a database server. 4 GB的RAM并不是很高的高端,尤其是对于数据库服务器。 You likely need more, but this is not to say 'just throw RAM' at your problem, the above items should still be investigated. 您可能还需要更多,但这并不是说要解决问题就是“仅将RAM扔掉”,仍应对上述各项进行调查。

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

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