I would like to explicitly "release" object instance resolved by Unity. I hoped the Teardown method should be used exactly for this so I tried something like this:
container.RegisterType(typeof(IMyType), typeof(MyType),
new MyLifetimeManager());
var obj = container.Resolve<IMyType>();
...
container.Teardown(obj);
MyLifetimeManager stores object instance in HttpContext.Current.Items. I expected that Teardown method will call RemoveValue on lifetime manager and release both MyType instance and lifetime manager instance. It doesn't work. First of all RemoveValue is not called and if I again call Resolve<IMyType> I will get previously resolved instance.
What should Teardown method do? How can I release object despite of his lifetime manager?
Edit:
If Teardown doesn't release the instance, who does? Who calls RemoveValue on lifetime manager?