.NET - Is there a way to change the GC behavior fo

2019-07-18 05:17发布

A co-worker said this is possible (but it looks a bit strange to me).
If there's a way to do it, where can I do this?
I'm talking about winXP OS.

1条回答
\"骚年 ilove
2楼-- · 2019-07-18 05:38

Yes, the GC has two modes of operation: Server and Workstation. You can change modes in either your app.config (per application) or machine.config. See http://blogs.msdn.com/junfeng/archive/2004/07/13/181534.aspx for more information.

<Configuration>
    <runtime>
        <gcServer enabled="false" />
        <gcConcurrent enabled="true" />
    </runtime>
</Configuration>

For gcServer:

  • false - Does not run server garbage collection. This is the default.
  • true - Runs server garbage collection.

For gcConcurrent:

  • false - Does not run garbage collection concurrently.
  • true - Runs garbage collection concurrently. This is the default.

In general, however, you don't want to change the GC operation mode, especially on a machine level unless you have a really, really good reason to. Generally the only things that care about this are unmanaged applications that are hosting the CLR themselves (such as SQL Server or IIS).

查看更多
登录 后发表回答