title: TypedFactory vs Performance Monitor
body: <p>I'm confused about how new windsor3 perfmonace counter shows tracking of objects generated via TyepedFactory.</p>
  
  <p>considering following scenario</p>
  
  <pre><code>public interface IBFactory
  {
      IB[] GetAll();
      void FreeUp(IB cmps);
  }
  
  public class B1 : IB, IDisposable
  {
      public void Add(int i){}
  
      public void Dispose()
      {
          Console.WriteLine("Disposing " + GetType().Name);
      }
  }
  
  public class B2 : IB, IDisposable
  {
      public void Add(int i){}
  
      public void Dispose()
      {
          Console.WriteLine("Disposing " + GetType().Name);
      }
  }
  
  public class B3 : IB
  {
      public void Add(int i){}
  
      public void Dispose()
      {
          Console.WriteLine("Disposing " + GetType().Name);
      }
  }
  
  
   var container = new WindsorContainer();
  
   var diagnostic = LifecycledComponentsReleasePolicy.GetTrackedComponentsDiagnostic(container.Kernel);
   var counter = LifecycledComponentsReleasePolicy.GetTrackedComponentsPerformanceCounter(new PerformanceMetricsFactory());
   container.Kernel.ReleasePolicy = new LifecycledComponentsReleasePolicy(diagnostic, counter);
  
   Console.WriteLine("Enter number of iterations:");
   int iterations = int.Parse(Console.ReadLine());
  
   container.AddFacility&lt;TypedFactoryFacility&gt;();
   container.Register
   (
      Component.For&lt;IBFactory&gt;()
          .AsFactory()
          .LifeStyle.Transient,
  
      Classes.FromAssemblyContaining&lt;IB&gt;()
          .BasedOn(typeof(IB))
          .WithService.Base()
          .Configure(c =&gt; c.LifestyleTransient())
   );
  
   Console.WriteLine("Create Memory Leak Y or N?");
   var leak = Console.ReadLine().ToUpper() == "Y";
  
  
   var sleepFor = 100;// int.Parse(Console.ReadLine());
  
   for (var i = 1; i &lt; iterations+1; i++)
   {
      var factory = container.Resolve&lt;IBFactory&gt;();
      Console.WriteLine("Factory created.");
  
      var cmp = factory.GetAll();
      foreach (var b in cmp)
      {
          b.Add(i);
      }
  
      Console.WriteLine("Iteration {0} completed", i);
  
      Thread.Sleep(sleepFor);
  
      if (!leak)
      {
          foreach (var b in cmp)
          {
              factory.FreeUp(b);
          }
      }
  
      Console.WriteLine("Releasing factory.");
      container.Release(factory);     
   }
  
   Console.WriteLine("container disposing.....");
   container.Dispose();
   Console.WriteLine("container disposed");
   Console.ReadLine();
  </code></pre>
  
  <p>If I dispose objects, as I should, via FreeUp factory method, perf counter shows expected tracking.</p>
  
  <p>Instead if I do not expliclty dispose objects, but if I'll do implicitly disposing the factory, created as transient for testing purpose, IB instances are disposed when I dispose the factory (as per documentation), but perf counter does not get updated and shows IB instance still as tracked...</p>
  
  <p>What that means?
  Perf counter has not been updated or objects are still tracked(that's would be very scary) even if Dispose has been called on IB instances due to factory disposing.</p>