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

(cherry picked from commit 904ad9c)
  • Loading branch information
roji committed Jun 12, 2019
1 parent f04e9ca commit a4c566b
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public virtual EntityFrameworkServicesBuilder TryAddCoreServices()
TryAdd<IParameterBindingFactory, EntityTypeParameterBindingFactory>();

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

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

0 comments on commit a4c566b

Please sign in to comment.