Unity Lifetimes: TearDown should dispose objects created by container
TearDown does not do anything with the LifetimeManagers supplied ootb. It should properly dispose object(graph)s created by the container
Rory Primrose commented
Bill, you are right that ContainerControlledLifetimeManager does disposal, but there are two issues with it. First, it is only done for that lifetime manager and all other managers don't run any disposal. Second, it only disposes the top level instance, not the entire object graph.
Bill Sorensen commented
This is not the case. ContainerControlledLifetimeManager disposes instances when the container is disposed.
Rory Primrose has developed a Unity Extension that seems to do just that, as part of the Neovolve Tookit, and written multiple articles about it (http://www.neovolve.com/post/2010/06/18/Unity-Extension-For-Disposing-Build-Trees-On-TearDown.aspx). I would really love to see this integrated into Unity, as properly disposing the object graph is something a DI container should be able to do. Creating and disposing child containers feels inappropriate in design, and HierarchicalLifetimeManager prevents from using any other lifestyle.
I agree. The pattern of creating a child container and disposing it is needlessly complex for what should be a simple Resolve<T>(), Release(x) interface.