1

As part of the graceful .NET 4.5 application shutdown I want to dispose the instance of Windsor Castle IoC container. The container has about 100 objects that were instantiated during the application lifetime and subset of them have IDisposable implemented that will be called as part of container dispose mechanism.

What I find surprising is that there is about of 10 seconds delay: - from the moment when I call container.Dispose() - to the moment when first Dispose() is called on one of the objects from the application

This increases application closing time to unacceptable level because now user must wait for more than 10 seconds for the application shutdown. (note: CPU is Intel i5 and there are 6gb of RAM)

I am not sure what logic is Windsor container executing under the hood but I was wondering is there any way I can reduce this delay?

matori82
  • 3,669
  • 9
  • 42
  • 64
  • Can you change your Composition Root to do (part of) the disposing yourself (e.g. for singletons)? – Maarten Apr 15 '14 at 09:24
  • 3
    Did you try a profiler run to see where the time is spent? – TomTom Apr 15 '14 at 09:44
  • @Maarten, could you elaborate a bit, not sure how to test your proposal? – matori82 Apr 15 '14 at 10:08
  • @TomTom, no I haven't... the code that is responsible for this delay is somewhere inside of _container.Dispose() before it actually starts calling Dispose() methods from my user code. So the bottleneck is inside of Windsor Castle container's code, so not sure if profilers can help in this case? If so can you recommend one? – matori82 Apr 15 '14 at 10:12
  • Any profiler should work. – TomTom Apr 15 '14 at 10:33
  • 2
    I bet this is not Castle's fault, but you're doing too much work in one of your `Dispose` methods. There's only one way to find out: profile! – Steven Apr 15 '14 at 14:39
  • That doesn't sound right. What is your performance profiler telling you? – Krzysztof Kozmic Apr 15 '14 at 21:50
  • The issue was with WCF facility I used for Windsor Castle. I resolved it by specifying "close timeout" to zero like this: _windsorContainer.AddFacility(f => f.CloseTimeout = TimeSpan.Zero); – matori82 Apr 16 '14 at 15:51

0 Answers0