Reputation: 364319
How costly (performance impact) is creating subcontainers in Unity 2.0? The scenario is for example web application or web service where main container is initialized on start of the application but each processed request has its own instace of subcontainer created from the main one. The configuration of the container will not change. The reason is usage of HierarchicalLifetimeManager
.
Upvotes: 2
Views: 540
Reputation: 233162
As always when the question is related to performance the answer is: measure your application to understand the performance implications for your specific application.
As a general observation, for mainstream applications that integrate with out-of-process resources (such as databases, web services, etc.), object composition is rarely a performance bottleneck. Compose your object graphs with confidence - odds are that the DI Container will not give you a measurable overhead.
Upvotes: 7