Open wlhappy01 opened 6 years ago
有多少服务,并发多少,docker 使用的是什么版本
经过检测dotnetty 0.5.0+版本会有内存泄漏的问题,现在已经降至0.4.8版本
fanliang11,您好,我下载了最新版本进行测试,发现用你的Demo示例内存并没有增加,但是我编写的业务组件则内存一直增加,奇怪的是在我并没有访问服务的情况下也是一直在增加,我对比了我写的业务组件与您的Demo(Surging.Modules.Common)的区别,如下:
1.我在业务组件中使用了Mongodb数据库 2.代码如下 服务 public class XXXXService : ProxyServiceBase,IXXXXService { private readonly MongoBaseRespository _repository; public MongoTestService(MongoBaseRespository repository) { this._repository = repository; } ............................................ } 数据库MongoBaseRespository
public class MongoBaseRespository : BaseRepository
{
///
public MongoBaseRespository()
{
//构建配置对象DBConfig
InitConfig();
}
#region 初始化数据库
/// <summary>
/// 构建mongodb配置文件对象
/// </summary>
private void InitConfig()
{
MongoDBConfig config = new MongoDBConfig();
if (UseSurging)
{
IConfigurationSection mongoSection = Surging.Core.CPlatform.AppConfig.GetSection("MongoDB");
if (mongoSection == null)
{
throw new ArgumentNullException("在surging appsettings.json中没有配置MongoDB配置节");
}
config.IpAddress = mongoSection["IpAddress"];
config.Port = mongoSection["Port"];
config.UserName = mongoSection["UserName"];
config.Password = mongoSection["Password"];
config.PoolMin = mongoSection["PoolMin"];
config.PoolMax = mongoSection["PoolMax"];
config.ConnectTimeOut = mongoSection["ConnectTimeOut"];
config.DataBase = mongoSection["DataBase"];
config.AuthDatabase = mongoSection["AuthDB"];
}
else
{
var build = new ConfigurationBuilder().AddJsonFile(CONFIG_FILE_NAME, true, true);
IConfigurationRoot configuration = build.Build();
config.IpAddress = configuration["MongoDB:IpAddress"];
config.Port = configuration["MongoDB:Port"];
config.UserName = configuration["MongoDB:UserName"];
config.Password = configuration["MongoDB:Password"];
config.PoolMin = configuration["MongoDB:PoolMin"];
config.PoolMax = configuration["MongoDB:PoolMax"];
config.ConnectTimeOut = configuration["MongoDB:ConnectTimeOut"];
config.DataBase = configuration["MongoDB:DataBase"];
config.AuthDatabase = configuration["MongoDB:AuthDB"];
}
DBConfig = config;
}
..............................................
}
因为我在测试服务器上并没有对服务进行访问,但内存还是在自己增长,但是我部署您编写的Demo则正常,实在想不出原因,水平有限,请教了~~~~
抱歉,我肉眼也看不出内存泄漏的问题,你可以用IDE内置工具来跟踪内存占用
fanliang11,我用IDE观察了内存变化,发现是一个StringBuilder对象一直增加,但不能查看对象引用位置,不知如何查看此StringBuilder对象所在位置,求大神指点,截图如下:
按照上面截图来看,应该是nlog出现的问题,Nlog写入file,还是Console?minlevel是什么,可以试试按照https://github.com/NLog/NLog/issues/2933 进行操作
在Rancher中监控到我部署的服务,在运行几天后内存占用到1个多G,我重启服务后内存占用又变为几十M,请问是什么原因?