예제 #1
0
 public void test()
 {
     using (var parentContainer = new WindsorContainer()) {
         parentContainer.Register(Component.For<Service1>().LifeStyle.Transient);
         for (var i = 0; i < 100000; i++) {
             using (IWindsorContainer childContainer = new WindsorContainer()) {
                 //childContainer.Kernel.ReleasePolicy = new LifecycledComponentsReleasePolicy();
                 parentContainer.AddChildContainer(childContainer);
                 var service1 = childContainer.Resolve<Service1>();
                 childContainer.Release(service1);
                 parentContainer.Release(service1);
                 if (i%100 == 0) {
                     GC.Collect(2);
                     Console.WriteLine("Iteration: {0}, Memory {1}", i, GC.GetTotalMemory(false));
                 }
                 parentContainer.RemoveChildContainer(childContainer);
             }
         }
     }
 }