ASP.NET Web 应用程序在部署后不会卸载 AppDomains [英] ASP.NET Web application doesn't unload AppDomains after deploy

查看:24
本文介绍了ASP.NET Web 应用程序在部署后不会卸载 AppDomains的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我们部署 Web 应用程序时,我们将所有代码复制到一个新目录,然后将 iis 指向该新目录.当我们这样做时,应用程序域的数量会增加但不会减少.此外,我们的 Application_End 事件似乎永远不会触发.

When we deploy our web application we copy all the code to a new directory and then point iis to that new directory. When we do this the number of appdomains increases but never decreases. Also, our Application_End event never seems to fire.

在某些未知的时间里,虽然 perfmon 仍会报告两组 AppDomain,但系统性能非常差,而 GC 中的时间百分比飙升至 100%.最终我回收了应用程序池,让应用程序再次顺利运行.

For some unknown time, while both sets of AppDomains are still reported by perfmon, the system performs very poorly while % time in GC spikes to 100%. Eventually I recycle the app pool to get the app running smoothly again.

额外信息:列出应用程序域在我的开发机器上显示 2 个,但在实时服务器上运行 4 个......我们只有一个应用程序在池中运行,所以这意味着我们正在使用的某个库是创建应用域.

我应该怎么做才能调试正在发生的事情?什么会阻止应用域卸载?

What should I do to try to debug what's happening? What would prevent an app domain from unloading?

2014 年 9 月 3 日更新

在获得一些更详细的日志信息后,问题似乎不是旧的应用程序域仍然存在,而是在重新启动期间创建的新应用程序域.应用程序不是启动一个新实例,而是启动两个.有时我们会从旧实例中获取 application_end,有时则不会.

After getting some more detail log information it looks like the problem is not old app domains staying around, it's new appdomains created during restart. Instead of the application starting one new instance, it starts two. Sometimes we get application_end from the old instance, sometimes we don't.

2014 年 9 月 4 日更新

这两件事都在发生.使用进程浏览器,我可以在其中一台机器上看到旧的应用程序域仍然存在,而一个新的应用程序域已经启动.在另一台机器上只有 2 个应用程序域,但它们的顺序 ID 存在差距.因此,两个实例启动了(我们也从应用启动中收到了一条日志消息),其中一个几乎立即消失了,留下了 2 个应用域.

Both things are happening. Using process explorer I can see on one of the machines that the old app domain is still there and a new one has started. On the other machine there were only 2 app domains but there was a gap in their sequential ids. So two instances started (we also get a log message from app start), one of them died off almost instantly, leaving 2 app domains.

推荐答案

虽然我不确定这是应用程序没有卸载 appdomains 的唯一原因,但它肯定是一个原因.实际的答案远没有我用来弄清楚的步骤那么有趣.

Although I am not sure this is the ONLY reason the app was not unloading appdomains, it certainly is one reason. The actual answer is much less interesting than the steps I used to figure it out.

  1. 我编写了一个小 ruby​​ 脚本,只在 10 个线程中针对我们的应用发出 100 个请求(设置 jmeter 需要比这更多的时间).
  2. 运行脚本并在运行时多次更改应用配置文件.这花了几分钟.
  3. 我使用进程资源管理器确认确实有 4 个应用域仍然加载到进程中.
  4. 我运行了 procdump 并创建了一个转储文件.
  5. 将 procdump 文件加载到 Visual Studio 并单击仅使用托管调试"(即使我不知道该错误是否在托管代码中)
  6. 调试器在调用 Application_End 的线程正在等待队列完成处理的代码行上停止.通过查看变量的值,我知道队列不再处理项目,但我们要等到队列为空.
  7. 更改代码并重新开始进程,这次我对网络配置的更改启动的所有应用程序域都已卸载.

这篇关于ASP.NET Web 应用程序在部署后不会卸载 AppDomains的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆