Cleanup after resolving instance via UnityContainer.Resolve(...)

Feb 10, 2011 at 10:08 PM

Title pretty much explains everything but here it goes in little more details:

I have a simple windows service that uses Unity to resolve dependencies; this service is only a few months old has been running in production for a handful of weeks. It doesn't do anything special but I see memory usage increase everytime UnityContainer.Resolve is called.

Do I need to call UnityContainer.TearDown(Object o) after I create an object using UnityContainer.Resolve(Type t) method call?

Let me know if you need more info and I'd be happy to provide that for you..

 

Cheers!

 

 

 

Feb 10, 2011 at 11:17 PM

No, you don't need to call TearDown - it doesn't actually do anything out of the box, it's there as a hook for extensions that need to clean up stuff.

Unity doesn't itself hold onto references unless you tell it to (by using ContainerControlledLifetimeManager, for example). If there's an actual leak, we'll need more information about the object graph you're resolving and what you're doing with those objects.

I don't currently know of any leaks in Unity proper, so if you can give me a repro case that would be a huge help in tracking it down.