• <tfoot id='vLkHd'></tfoot>

      <bdo id='vLkHd'></bdo><ul id='vLkHd'></ul>

    1. <legend id='vLkHd'><style id='vLkHd'><dir id='vLkHd'><q id='vLkHd'></q></dir></style></legend>

      1. <i id='vLkHd'><tr id='vLkHd'><dt id='vLkHd'><q id='vLkHd'><span id='vLkHd'><b id='vLkHd'><form id='vLkHd'><ins id='vLkHd'></ins><ul id='vLkHd'></ul><sub id='vLkHd'></sub></form><legend id='vLkHd'></legend><bdo id='vLkHd'><pre id='vLkHd'><center id='vLkHd'></center></pre></bdo></b><th id='vLkHd'></th></span></q></dt></tr></i><div id='vLkHd'><tfoot id='vLkHd'></tfoot><dl id='vLkHd'><fieldset id='vLkHd'></fieldset></dl></div>
      2. <small id='vLkHd'></small><noframes id='vLkHd'>

      3. 在短时间内阻止 .NET 垃圾收集

        时间:2023-09-13
        <tfoot id='QhRgJ'></tfoot>

              • <bdo id='QhRgJ'></bdo><ul id='QhRgJ'></ul>
              • <small id='QhRgJ'></small><noframes id='QhRgJ'>

                <i id='QhRgJ'><tr id='QhRgJ'><dt id='QhRgJ'><q id='QhRgJ'><span id='QhRgJ'><b id='QhRgJ'><form id='QhRgJ'><ins id='QhRgJ'></ins><ul id='QhRgJ'></ul><sub id='QhRgJ'></sub></form><legend id='QhRgJ'></legend><bdo id='QhRgJ'><pre id='QhRgJ'><center id='QhRgJ'></center></pre></bdo></b><th id='QhRgJ'></th></span></q></dt></tr></i><div id='QhRgJ'><tfoot id='QhRgJ'></tfoot><dl id='QhRgJ'><fieldset id='QhRgJ'></fieldset></dl></div>

                  <tbody id='QhRgJ'></tbody>
                • <legend id='QhRgJ'><style id='QhRgJ'><dir id='QhRgJ'><q id='QhRgJ'></q></dir></style></legend>
                • 本文介绍了在短时间内阻止 .NET 垃圾收集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个处理大量数据的高性能应用程序.它在很短的时间内接收、分析和丢弃大量信息.这会导致我目前正在尝试优化的大量对象流失,但它也会导致次要问题.当垃圾收集启动时,它会在清理东西时导致一些长时间的延迟(我的意思是 10 到 100 毫秒).99% 的时间这是可以接受的,但是对于大约 1-2 分钟的短暂时间窗口,我需要绝对确定垃圾收集不会导致延迟.我知道这些时间段何时会发生,我只需要一种方法来确保在此期间不会发生垃圾收集.该应用程序是使用 .NET 4.0 Framework 用 C# 编写的,如果重要的话,它会使用托管代码和非托管代码.

                  I have a high performance application that is handling a very large amount of data. It is receiving, analysing and discarding enormous amounts of information over very short periods of time. This causes a fair amount of object churn that I am currently trying to optimize, but it also causes a secondary problem. When Garbage Collection kicks in it can cause some long delays as it cleans things up (by long I mean 10s to 100s of milliseconds). 99% of the time this is acceptable, but for brief windows of time about 1-2 minutes long I need to be absolutely sure that Garbage Collection does not cause a delay. I know when these periods of time will occur beforehand and I just need a way to make sure that Garbage collection doesn't happen during this period. The application is written in C# using .NET 4.0 Framework and uses both managed and unmanaged code if that matters.

                  我的问题是;

                  1. 是否可以暂时暂停整个程序的垃圾收集?
                  2. 是否可以在我需要释放垃圾收集的窗口之前使用 System.GC.Collect() 强制进行垃圾收集,如果这样做,我将在多长时间内释放垃圾收集?
                  3. 人们对最大限度地减少对垃圾收集的总体需求有何建议?

                  注意 - 这个系统相当复杂,包含许多不同的组件.我希望避免采用必须在程序的每个类上实现自定义 IDisposable 接口的方法.

                  Note - this system is fairly complex with lots of different components. I am hoping to avoid going to a approach where I have to implement a custom IDisposable interface on every class of the program.

                  推荐答案

                  .NET 4.6 增加了两个新方法:GC.TryStartNoGCRegionGC.EndNoGCRegion 就是为了这个.

                  .NET 4.6 added two new methods: GC.TryStartNoGCRegion and GC.EndNoGCRegion just for this.

                  这篇关于在短时间内阻止 .NET 垃圾收集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:为什么选择大对象堆,我们为什么要关心? 下一篇:为什么 System.Timers.Timer 能在 GC 中存活,而 System.Threading.Timer 不

                  相关文章

                    <bdo id='BlUdy'></bdo><ul id='BlUdy'></ul>
                • <small id='BlUdy'></small><noframes id='BlUdy'>

                  1. <tfoot id='BlUdy'></tfoot>
                    <i id='BlUdy'><tr id='BlUdy'><dt id='BlUdy'><q id='BlUdy'><span id='BlUdy'><b id='BlUdy'><form id='BlUdy'><ins id='BlUdy'></ins><ul id='BlUdy'></ul><sub id='BlUdy'></sub></form><legend id='BlUdy'></legend><bdo id='BlUdy'><pre id='BlUdy'><center id='BlUdy'></center></pre></bdo></b><th id='BlUdy'></th></span></q></dt></tr></i><div id='BlUdy'><tfoot id='BlUdy'></tfoot><dl id='BlUdy'><fieldset id='BlUdy'></fieldset></dl></div>
                  2. <legend id='BlUdy'><style id='BlUdy'><dir id='BlUdy'><q id='BlUdy'></q></dir></style></legend>