Determining which garbage collector is running(确定正在运行的垃圾收集器)
问题描述
我在 Windows Server 2003 x64(2x Xeon 4 核心 procs)上运行一个大型 .net 4.0 x86 应用程序,并且遇到问题,我的应用程序每天大约 2-3 次冻结 30 秒,然后恢复运行像平常一样.该应用程序每周仅重新启动一次,并消耗 400-800 mb 的内存,所以我假设这些冻结是垃圾收集.我只在日志中看到冻结,而不是实时,或者我会检查任务管理器来确认.
I am running a large .net 4.0 x86 app on Windows Server 2003 x64 (2x Xeon 4 core procs), and am running into issues where my app ~2-3 times a day freezes for 30 seconds, and then resumes functioning as normal. The application is only rebooted once a week, and consumes 400-800 mb of memory, so I am assuming these freezes are Garbage Collection. I am only seeing the freezes in the logs, not live, or I would check the Task Manager to confirm.
我试图弄清楚哪个 .Net 4 GC 正在运行,以及如何将 GC 切换到新的并发后台 gc(如果不是),或者如何确认这些实际上是 GC(Procmon 没有在 Win2k3 服务器中显示 .Net 工具).
I am trying to figure out which .Net 4 GC is running, and how to either switch the GC to the new concurrent background gc if it isn't, or how to confirm these are in fact GCs (Procmon doesn't show .Net instruments in Win2k3 server).
推荐答案
你运行的是服务器版的Windows,默认会得到服务器版的垃圾回收器.它不进行后台收集,垃圾由多个线程收集,因此偶尔可观察到的暂停并不罕见.您可以使用 app.exe.config 文件强制工作站版本:
You are running on the server version of Windows, you'll get the server version of the garbage collector by default. Which doesn't do background collections, garbage is collected by multiple threads so occasional observable pauses are not unusual. You can force the workstation version with an app.exe.config file:
<configuration>
<runtime>
<gcServer enabled="false"/>
</runtime>
</configuration>
同时查看 GC.RegisterForFullGCNotification() 处理暂停副作用的方法.
Also review the docs for the GC.RegisterForFullGCNotification() method for a way to deal with the side-effect of the pauses.
.NET 4.5 版将支持服务器 GC 的后台收集.
.NET version 4.5 will support background collections for the server GC.
这篇关于确定正在运行的垃圾收集器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:确定正在运行的垃圾收集器
基础教程推荐
- c# Math.Sqrt 实现 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- rabbitmq 的 REST API 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01