1

I'm interested in knowing if there are any advantages to creating a child container for each request in a web based application?

The tech stack I'm using includes StructureMap & ASP.NET MVC, which is not particularly relevant but included as background info.

AwkwardCoder
  • 24,893
  • 27
  • 82
  • 152

1 Answers1

0

Without a child container, the application container would otherwise be responsible for holding all instances created during the application's lifetime.

That is an enormous memory leak.

Bryan Watts
  • 44,911
  • 16
  • 83
  • 88
  • Surely this an assumption of how the container is implemented and it disposes of instances? – AwkwardCoder Jun 07 '10 at 22:58
  • 1
    @AWC: I am making the assumption that containers, in general, track the instances they create. That is a solid assumption for any implementation of an IoC container, otherwise "container" wouldn't be a very fitting name. I make no assumptions about disposal: I simply mean that if a container goes out of scope, its objects go with it. – Bryan Watts Jun 08 '10 at 00:01