abp框架 设置GC模式

在对应 api项目文件名下的有一个runtimeconfig.json文件
例如ProjectName.HttpApi.Host.runtimeconfig.json,如果看不到 就查看 所有文件,如果全局查会出现多个文件,确定修改的是对的。
在json文件中设置configProperties中的System.GC.Server,如果 是true,默认是服务器模式,设置为false默认是Workstation模式。

检查GC模式:
在module中添加

public override void PreConfigureServices(ServiceConfigurationContext context)
{
    // var configuration = context.Services.GetConfiguration();
    // 获取当前的垃圾回收器
    var currentGcMode = GCSettings.IsServerGC ? "Server" : "Workstation";
    Log.Information("当前垃圾回收模式:" + currentGcMode);
    // Configure(configuration.GetSection("GCSettings"));
    // 设置垃圾回收模式为服务器模式
    // GCSettings.IsServerGC = true;
    // Log.Information("已将垃圾回收模式设置为服务器模式");
}

在PreConfigureServices中打印日志就可以看到GC模式的变化。

你可能感兴趣的:(c#)