简体   繁体   English

为什么并发GC有时会导致ExecutionEngineException(每个MSDN)?

[英]Why does concurrent GC sometimes cause ExecutionEngineException (per MSDN)?

According to MSDN , there is a "tip" stating that a .NET application running under heavy load with concurrent garbage collection (either <gcConcurrent enabled="true"/> or unspecified, since it's the default behavior) may throw an ExecutionEngineException. 根据MSDN的说法,有一个“提示”指出,在带有并发垃圾收集的重负载下运行的.NET应用程序( <gcConcurrent enabled="true"/>或未指定,因为它是默认行为)可能会抛出ExecutionEngineException。 Is anyone aware of a Microsoft KB article or other source that provides additional background on this? 是否有人知道Microsoft知识库文章或其他来源提供了额外的背景知识?

We have experienced this directly with an NHibernate 3.2-based Windows Service application, which will invariably crash after at most a few hours of operation. 我们直接使用基于NHibernate 3.2的Windows服务应用程序来体验这一点,该应用程序在最多几个小时的运行后总会崩溃。 We were able to track down the exception to the ISession.Flush() call. 我们能够跟踪ISession.Flush()调用的异常。

There's a thread on nhusers reporting what appears to be the same problem. nhusers上有一个线程报告似乎是同一个问题。 His suggested workaround, which was to disable concurrent GC, has worked for us so far, although switching to server-mode GC ( <gcServer enable="true"/> ), which implicitly disables concurrent GC, also did the trick. 他建议的解决方法,即禁用并发GC,到目前为止对我们<gcServer enable="true"/> ,虽然切换到服务器模式GC( <gcServer enable="true"/> ),隐式禁用并发GC,也做了伎俩。

Before submitting this to MS as a bug, I'd like to find out if anyone out there has additional information on the concurrent GC instablity that the tip mentions. 在将此作为错误提交给MS之前,我想知道是否有人提供有关并发GC不稳定性的其他信息。

I suspect this occurs when the application is under heavy load because when concurrent GC is enabled, the GC tries to do it's work without pausing your application. 我怀疑当应用程序负载很重时会发生这种情况,因为当启用并发GC时,GC会尝试在不暂停应用程序的情况下执行此操作。 If the GC encounters a situation where it tries to move memory around during the compaction phase of a GC cycle and isn't able to move the memory or isn't able to correctly update the application pointers, that could cause the runtime to throw this exception since it would end up putting your application into a potentially invalid state. 如果GC在GC循环的压缩阶段遇到尝试移动内存但无法移动内存或无法正确更新应用程序指针的情况,则可能导致运行时抛出此内容异常,因为它最终会使您的应用程序进入可能无效的状态。

As @casperOne pointed out in his comment, this exception is marked as obsolete in .NET 4.0 although that doesn't necessarily mean the GC still can't get itself into the same state that caused it to throw the exception in .NET 3.5. 正如@casperOne在他的评论中指出的那样,这个例外在.NET 4.0中被标记为过时,尽管这并不一定意味着GC仍然无法进入导致它在.NET 3.5中引发异常的相同状态。 If the GC did get itself into that same state, the runtime will issue a FailFast command and terminate rather than throwing an exception. 如果GC确实进入同一状态,则运行时将发出FailFast命令并终止而不是抛出异常。

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

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