0

I want to use server background GC for an application and i want to enable this from code. So is it possible to set the equivalent of

<configuration>
  <runtime>
    <gcServer enabled=”true”/>
  </runtime>
</configuration>

from app.config, in code?

FS'Wæhre
  • 196
  • 2
  • 16
  • You can also do it with environment variables, consider setting them with a little helper app that uses the Process class to start the main app. COMPLUS_gcAllowVeryLargeObjects=1 works well. But sadly COMPLUS_gcServer=1 only works on CoreCLR. – Hans Passant Feb 13 '17 at 11:01

1 Answers1

2

This has to happen before the application (and to some extent, the CLR) is loaded. Unless you're making your own CLR host, by the time your application actually runs it's too late to change it.

Luaan
  • 62,244
  • 7
  • 97
  • 116