-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix memory leak caused by use of ThreadLocal<bool> inside CyclicDependencyValidator #956
Comments
The tricky part here is to ensure
|
I think this issue about |
…alidator. Instead, it now stores thread ids. Fixes #956
Awesome work. |
Simple Injector's internally creates a
CyclicDependencyValidator
instance per registration. EachCyclicDependencyValidator
uses its ownThreadLocal<bool>
instance, but this causes severe memory pressure (leak) when uses in combination with a large amount of registrations or with a large amount of container instances.Related:
A
ThreadLocal<T>
causes a memory leak in case its not disposed of properly. Although the amount of memory isn't that big, it will count up in case manyThreadLocal<T>
instances are created, as is the case with theCyclicDependencyValidator
. EachInstanceProducer
has its ownCyclicDependencyValidator
intance, and although theInstanceProducer
removes the reference to itsCyclicDependencyValidator
when its no longer of use, the underlyingThreadLocal<bool>
is not disposed of.This causes memory issues as reported by @andreminelli here:
The text was updated successfully, but these errors were encountered: