Skip to content

Commit

Permalink
Fix DiagnosticListener memory leak
Browse files Browse the repository at this point in the history
When IsConfigured is called, it applies all services. This caused a
DiagnosticListener to get instantiated on each DbContext instantiation,
and since it wasn't disposed it caused a leak.

Fixes #15173
  • Loading branch information
roji committed Jun 12, 2019
1 parent 073ca25 commit 5fc73a3
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public virtual EntityFrameworkServicesBuilder TryAddCoreServices()
TryAdd<IShapedQueryOptimizerFactory, ShapedQueryOptimizerFactory>();

ServiceCollectionMap
.TryAddSingleton<DiagnosticSource>(new DiagnosticListener(DbLoggerCategory.Name));
.TryAddSingleton<DiagnosticSource>(p => new DiagnosticListener(DbLoggerCategory.Name));

ServiceCollectionMap.GetInfrastructure()
.AddDependencySingleton<LazyLoaderParameterBindingFactoryDependencies>()
Expand Down

0 comments on commit 5fc73a3

Please sign in to comment.