From 0930a6d28e419ed3c80dba15be63103b2e38115d Mon Sep 17 00:00:00 2001 From: dpreece Date: Fri, 30 Aug 2019 09:10:02 -0600 Subject: [PATCH] Updated InternalRegistration Set method to update node if there is an existing node with the key instead of always inserting. The always inserting functionality was causing a memory leak with the Unity.Interception because the PreBuildUp was always inserting a new node on every resolve. --- src/Registration/InternalRegistration.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Registration/InternalRegistration.cs b/src/Registration/InternalRegistration.cs index 4cc141da6..fda11891f 100644 --- a/src/Registration/InternalRegistration.cs +++ b/src/Registration/InternalRegistration.cs @@ -61,6 +61,17 @@ public virtual void Set(Type policyInterface, object policy) } else { + for (var node = (LinkedNode)this; node != null; node = node.Next) + { + if (node.Key == policyInterface) + { + // Found it + node.Value = policy; + return; + } + } + + // If not found, insert after the current object Next = new LinkedNode { Key = policyInterface,