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

Remove the use of ThreadLocal<T> in the decorator sub system #540

Open
dotnetjunkie opened this Issue Apr 26, 2018 · 0 comments

Comments

1 participant
@dotnetjunkie
Copy link
Collaborator

dotnetjunkie commented Apr 26, 2018

The use of ThreadLocal<T> within Simple Injector is problematic, whenever the user creates an infinite number of Container instances (which btw is a practice that is not encouraged). ThreadLocal<T> causes memory leaks when it is not disposed properly.

The decorator sub system currently makes use of ThreadLocal<T> instances to build a list of decorators used for a given registration. This information is then provided to predicates, to allow decorators to be applied conditionally.

Changes should be made to the decorator sub system, in such way that ThreadLocal<T> is only used for a short period of time (during the time that ExpressionBuilt events are running, for instance), so that caching of ThreadLocal<T> instance for the duration of the container can be prevented.

This prevents memory leaks, such as described in #539.

@dotnetjunkie dotnetjunkie added this to the Backlog milestone Apr 26, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment