Asp.net core 2.1 EF
Centos7 1Core 1G
Previously, Windows was running on IIS, using the sqlserver database. In the first two weeks, it was replaced by Centos, using nginx as a proxy, and the database was replaced by sqlite3.
At the beginning, the Centos system swap space is about 200MB, the site runs for one day, the memory accounts for 90%, the swap runs out, the dotnet process is killed; the swap set 2GB later, persists for about a week, the swap runs out, and the dotnet process is killed.
As long as you visit the site, the memory footprint will gradually increase and will not be released; IIS runs completely without these problems on Windows.
The difference between them is that the database is different, one is sqlserver and the other is sqlite3;


@netnr It's unlikely we will be able to figure out what is happening without a solution/project or code listing that reproduces what you are seeing. Are you able to distill the scenario down into something that we can use to investigate?
After testing, using SQL to query memory without EF will not always increase

@netnr
optionsBuilder.UseLoggerFactory(new LoggerFactory(new[]
{
new ConsoleLoggerProvider((category, level)
=> category == DbLoggerCategory.Database.Command.Name
&& level == LogLevel.Error, true)
}));
don't create new LoggerFactory each time.
you can see this https://docs.microsoft.com/en-us/ef/core/miscellaneous/logging
so,it's you code bug.
国内很多文档在打印日志都这么写,然后上线之后内存暴涨,坑人不浅。
@linkinshi Resolved issue, thanks
Most helpful comment
@netnr
optionsBuilder.UseLoggerFactory(new LoggerFactory(new[]
{
new ConsoleLoggerProvider((category, level)
=> category == DbLoggerCategory.Database.Command.Name
&& level == LogLevel.Error, true)
}));
don't create new LoggerFactory each time.
you can see this https://docs.microsoft.com/en-us/ef/core/miscellaneous/logging
so,it's you code bug.
国内很多文档在打印日志都这么写,然后上线之后内存暴涨,坑人不浅。