We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 3ca27f8 + ba23a02 commit 937f0abCopy full SHA for 937f0ab
src/Autofac/Core/Registration/DefaultRegisteredServicesTracker.cs
@@ -247,6 +247,18 @@ protected override void Dispose(bool disposing)
247
registration.Dispose();
248
}
249
250
+ // If we do not explicitly empty the ConcurrentBag that stores our registrations,
251
+ // this will cause a memory leak due to threads holding a reference to the bag.
252
+ // In netstandard2.0 the faster 'Clear' method is not available,
253
+ // so we have do this manually. We'll use the faster method if it's available though.
254
+#if NETSTANDARD2_0
255
+ while (_registrations.TryTake(out _))
256
+ {
257
+ }
258
+#else
259
+ _registrations.Clear();
260
+#endif
261
+
262
base.Dispose(disposing);
263
264
0 commit comments