确定正在运行的垃圾收集器

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# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
quot;Overflowquot; compiler error with -9223372036854775808L(编译器错误-9223372036854775808L(Q;溢出Q))
Visual Studio 2010 ReportViewer Assembly References(Visual Studio 2010 ReportViewer程序集引用)
Weird behaviour when I open a reportviewer in WPF(在WPF中打开报表查看器时出现奇怪的行为)
how do i pass parameters to aspnet reportviewer(如何将参数传递给aspnet report查看器)