You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Stopping and disposing an instance of IHost leaves FileSystemWatchers, causing a small memory leak.
Seems to be related to the default configuration files it tries to watch.
To Reproduce
Using the Standard .Net 5 Console App template in Visual studio.
private static async Task Main(string[] args)
{
var loopCount = 0;
while (true)
{
loopCount++;
using var host = Host.CreateDefaultBuilder()
.Build();
await host.StartAsync();
await host.StopAsync();
GC.Collect();
GC.WaitForPendingFinalizers();
Console.WriteLine($"Completed loop {loopCount}");
}
}
Running the above code, note the memory usage of the console app consistently goes up.
After ~15000 loops it was using ~200mb of memory.
Looking at the memory snapshot I can see there seems to be 1 FileSystemWatcher (And related things) stuck for every loop that occurs.
I found that clearing the config sources by running
Describe the bug
Stopping and disposing an instance of IHost leaves FileSystemWatchers, causing a small memory leak.
Seems to be related to the default configuration files it tries to watch.
To Reproduce
Using the Standard .Net 5 Console App template in Visual studio.
Running the above code, note the memory usage of the console app consistently goes up.
After ~15000 loops it was using ~200mb of memory.
Looking at the memory snapshot I can see there seems to be 1 FileSystemWatcher (And related things) stuck for every loop that occurs.
I found that clearing the config sources by running
seemingly removes the issue. So I assume that the leak is coming from the setup of the default configuration.
The text was updated successfully, but these errors were encountered: