.net core 如何将服务器垃圾收集与dotnet fsi结合使用?
我想将服务器垃圾收集与dotnetfsi一起使用。我该怎么做 垃圾收集应通过以下两个源中引用的运行时设置进行配置: 我正在使用windows和Dotnet5预览sdk.net core 如何将服务器垃圾收集与dotnet fsi结合使用?,.net-core,f#,f#-interactive,.net Core,F#,F# Interactive,我想将服务器垃圾收集与dotnetfsi一起使用。我该怎么做 垃圾收集应通过以下两个源中引用的运行时设置进行配置: 我正在使用windows和Dotnet5预览sdkdotnetfsi运行良好 我制作了以下fsi.runtimeconfig.json文件,并将其放置在C:\Program Files\dotnet: { "runtimeOptions": { "configProperties": { "System.GC.Server": true
dotnetfsi
运行良好
我制作了以下fsi.runtimeconfig.json
文件,并将其放置在C:\Program Files\dotnet
:
{
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
}
}
但是,当我调用dotnet fsi--runtimeconfig fsi.runtimeconfig.json
时,我得到以下错误:
> dotnet fsi --runtimeconfig "fsi.runtimeconfig.json"
error FS0243: Unrecognized option: '--runtimeconfig'
Exception by fsi.exe:
System.Exception: Error creating evaluation session: StopProcessingExn None
at Microsoft.FSharp.Core.PrintfModule.PrintFormatToStringThenFail@1639.Invoke(String message) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\printf.fs:line 1639
at FSharp.Compiler.Interactive.Shell.FsiCommandLineOptions..ctor(FsiEvaluationSessionHostConfig fsi, String[] argv, TcConfigBuilder tcConfigB, FsiConsoleOutput fsiConsoleOutput) in F:\workspace\_work\1\s\src\fsharp\fsi\fsi.fs:line 726
at FSharp.Compiler.Interactive.Shell.FsiEvaluationSession..ctor(FsiEvaluationSessionHostConfig fsi, String[] argv, TextReader inReader, TextWriter outWriter, TextWriter errorWriter, Boolean fsiCollectible, FSharpOption`1 legacyReferenceResolver) in F:\workspace\_work\1\s\src\fsharp\fsi\fsi.fs:line 2484
at FSharp.Compiler.Interactive.Shell.FsiEvaluationSession.Create(FsiEvaluationSessionHostConfig fsiConfig, String[] argv, TextReader inReader, TextWriter outWriter, TextWriter errorWriter, FSharpOption`1 collectible, FSharpOption`1 legacyReferenceResolver) in F:\workspace\_work\1\s\src\fsharp\fsi\fsi.fs:line 2825
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at System.Lazy`1.get_Value()
at Sample.FSharp.Compiler.Interactive.Main.evaluateSession(String[] argv) in F:\workspace\_work\1\s\src\fsharp\fsi\fsimain.fs:line 269
如果省略运行时配置选项,则fsi将启动,但对于MacOs/linux而言,System.runtime.GCSettings.IsServerGC
为false
:
您需要更改dotnet.runtimeconfig.json。位于最新的dotnet SDK版本中,例如/usr/local/share/dotnet/SDK/3.1.301
对于Windows:
您需要更改位于Fsharp文件夹中的fsi.runtimeconfig.json以获得最新SDK版本,例如C:\Program Files\dotnet\SDK\5.0.100-preview.4.20258.7\Fsharp
dotnetfsi
> System.Runtime.GCSettings.IsServerGC;;
val it : bool = true
好的,这有帮助。我在Windows上找到了要更改的正确文件,需要更改的文件(根据sdk版本进行调整)位于
C:\Program Files\dotnet\sdk\5.0.100-preview.4.20258.7\FSharp\fsi.runtimeconfig.json
。您确定它在MacOS上是dotnet.runtimeconfig.json,而不是MacOS上等效的fsi.runtimeconfig吗?@nh2这取决于您如何运行fsi。如果您运行dotnet fsi,那么它就是dotnet.runtimeconfig.json。有一个fsi.runtimeconfig.json,但这是针对fsi.exe的,而.exes在linux中不起作用。好的,一定是windows的差异。我从windows运行dotnet fsi,但它使用fsi.runtimeconfig.json,因为它显然调用了fsi.exe。谢谢你的帮助!是否要更新答案以指向windows上的位置?对于mac用户,请在/usr/share/dotnet/sdk/5.0.202/FSharp/fsi.runtimeconfig.json中进行更改,即使运行dotnet fsi
。编辑dotnet.runtimeconfig.json
> System.Runtime.GCSettings.IsServerGC;;
val it : bool = true