-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
Method injection call handler not being released #21
Comments
Could it be the same issue? |
I'm not sure why the message posted before I was finished. I will continue here: I registered the class in two different ways: or It didn't have any impact on it. I have tested it by repeatably calling I can put a breakpoint on the destructor of the MemoizationCallHandler and then execute In Unity 2x, the breakpoints on the call handler will be hit, indicating it is being freed. In 5x, they are not being hit. We have a long running process that typically runs about 8 hours, with a significant number of calls to a variety of repositories, many have which have call handlers associated with them. With the upgrade to 5x, the server ran very low on memory and it took over 26 hours to complete. We have the source code to 5.8.11 but have been unable to determine where the reference to the call handler is being stored. Any help would be greatly appreciated. The upgrade to 5x significantly improved performance in resolving objects, but the memory loss has made it unusable for us. |
It is possible it is related to the issue you referenced. Thanks for the very quick response. I will get the latest build and see if that fixes it. |
Unfortunately that did not work. I upgraded to 5.8.13 and am still getting the same results. The call handlers do not appear to be releasing until I dispose of the UnityContainer. I'm testing this in our full application, but I can try to put together a small test app to get to you. |
Please do, otherwise I would have no idea what is wrong. |
I am attaching a zip file with two projects in it - one for 5.8.13 and one using the old Unity 2x. I create three instances of the repository class that has a call handler based attribute. After that I run the garbage collector to see what is being released. In the 2x version, you can see that the MemoizationCallHandler is being released at the same time as the TestRepository class. However, in the 5x version, you can see that the MemoizationCallHandler is not being released until the UnityContainer is disposed. For some reason in 2x there appear to be 2 instances of the MemoizationCallHandler for each TestRepository, Please let me know if you need anything else from me on this. Thank you. |
Could you verify if new version of Unity has the same issue? |
I will get it installed and tested. It may take a couple of days to get to it.
Thanks,
Carl
|
Carl, Did upgrading to a newer version resolve this problem for you? I believe I may be experiencing the same problem. I'm on 5.8.12. |
Did upgrading to a newer version resolve this problem for you? I believe I may be experiencing the same problem. I'm on 5.8.12. |
@ENikS I'm working on seeing if I can create a unit tests that detects this issue, but I'm not super familiar with the architecture of the unity interception so its going to take me some time to come up with something but I thought I'd mention what we found in case you could understand and fix what is causing the memory leak just from my description of the problem. Thanks, Dan |
Some more information. In Unity 4.x, in the TypeInterceptionStrategy PreBuildup method, it makes the following call:
In Unity 5.x, it makes a similar call:
In Unity 4.x the implementation of the Set method on the PolicyList was:
While in 5.x it is
It looks like the 4.x implementation would have replaced the "EffectiveInterceptionBehaviorsPolicy" in the dictionary it used where in 5.x we are always inserting into the linked list without checking if the policy is already in the list. |
I've created a pull request with a potential fix for this: unitycontainer/container#175 |
@ENikS Any comment on what I found above? |
We are attempting to upgrade from Unity 2x to Unity 5.8.11. Everything appears to be working except that the memory allocated for CallHandlers associated with a class that uses a TransientLifetimeManager is not be released by Unity.
I have tried registering the class two different ways with the same result:
The text was updated successfully, but these errors were encountered: