Skip to content
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

What's best way to get .net 3.5 SimpleInjector Decorator Memory Leak bug fix? #995

Open
Zayik opened this issue Apr 8, 2024 · 1 comment
Labels

Comments

@Zayik
Copy link

Zayik commented Apr 8, 2024

Problem:
SimpleInjector 1.6 contains memory leak when using decorators.
I'm stuck on legacy tools/hardware from both internal use, and 3rd party that cannot be upgraded to newer .net.
Container is instantiated periodically based on user configurations. Programs have typical lifespans of weeks, thus causing memory leaks that get noticeably large (upwards of 4GB seen).

Example code that causes memory leak:
container.Register<IAnimal, Dog>();
container.RegisterDecorator(typeof(IAnimal), typeof(AnimalHandler));
container.GetInstance().Speak();

Goal:
Version of SimpleInjector that supports .net 3.5 and eliminates the decorator memory leak.

Questions:
What is the recommended route to achieve this?

Thoughts:

  1. Pull down 3.1.1 and backport to .net 3.5.
  2. Find the equivalent change in 1.6 and make it. (I'm not entirely certain what that equivalent change would be.)

Any help/suggestions would be greatly appreciated.

@Zayik Zayik added the question label Apr 8, 2024
@dotnetjunkie
Copy link
Collaborator

In the /src folder there is a changes.txt file. It has been abandoned after the release of v4.0.0, in favor of simply tracking changes in the Github release notes. That changes.txt contains information of v2.0.0 (information that isn't available elsewhere because Simple Injector was still on Codeplex back than, but that website no longer exists). The change list for v2.0 notes that a bug concerning a memory leak in decorators was fixed. This might be a starting point for you.

So perhaps you can find the bug fix in source control (as all former Codeplex commits were ported to the Github git repo). You can cherriepick this change in your custom branch that you took from the latest v1.x release. You can build your own Simple Injector version based on this. Note that you won't be able to sign the assembly, but that should typically not be an issue.

I hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants