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.