Thanks for your reply. I thought that in a server web services application, parent/child would be the best approach to take because the registration of components would occur just once (on the parent container) and then a child container would be instantiated for the lifecycle of each web service call that comes in. This avoids the performance hit of component registration for each call that comes in.
That was my thinking but I'm new to IoC containers :) On Nov 30, 2:36 pm, Mauricio Scheffer <[email protected]> wrote: > Looks like an issue with child containers... what's your scenario for > choosing child containers? > > -- > Mauricio > > On Nov 30, 3:34 pm, Matt Lund <[email protected]> wrote: > > > I've read several articles about release policies, and it's only > > reluctantly that I post this because I'm sure I must be doing > > something dumb. > > > I would expect the following code to exhibit a low/constant memory > > consumption. But instead, it builds very quickly to the point that > > it'll run out of memory. > > > I think I may be having a problem getting the child container to be > > released from the parent container but I'm not sure. Any ideas? > > > class Program > > { > > static void Main(string[] args) > > { > > IWindsorContainer parentContainer = new > > WindsorContainer(); > > > parentContainer.Register(Component.For<Service1>().ImplementedBy<Service1>( > > ).LifeStyle.Transient); > > > for (int i = 0; i < 100000; i++) > > { > > using (IWindsorContainer childContainer = > > new WindsorContainer()) > > { > > childContainer.Kernel.ReleasePolicy > > = new > > LifecycledComponentsReleasePolicy(); > > > > parentContainer.AddChildContainer(childContainer); > > > Service1 service1 = > > (Service1)childContainer.Resolve(typeof(Service1)); > > service1.Method1(); > > > childContainer.Release(service1); > > > if (i % 100 == 0) > > { > > GC.Collect(2); > > > > Console.WriteLine("Iteration: {0}, Memory {1}", i, > > GC.GetTotalMemory(false)); > > } > > > > > parentContainer.RemoveChildContainer(childContainer); > > } > > } > > } > > } > > > public class Service1 > > { > > private byte[] big = new byte[1000000]; > > > public void Method1() > > { > > } > > } -- You received this message because you are subscribed to the Google Groups "Castle Project Users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.
