Hello,
It is a bit unknown fact that Windsor keeps
references to resolved components and that they should be “released” via
IWindsorContainer.Release() call (google for release policy in Windsor).
I think that NServiceBus misses this
requirement in its design which results in memory leaks. For example message
handlers are registered in the container with transient lifestyle (using
Windsor nomenclature) but there is no mechanism in NServiceBus that would
release them. This means that every processed message leaves whole object
graphs leaked and left in the container.
This is most problematic with message
handlers, because of their “short” lifetime and potentially frequent
instantiation, but it may just as well affect other components of NServiceBus.
I think that for a solution the object
builder interface of NServiceBus should be extended with “release” method and
instantiated components should be released through it by the framework in
appropriate places. This would, for example, resemble controller factories in
both Castle Monorail and ASP.NET MVC – they both have a “release” method even
though with many underlying containers they actually are no-ops.
Kind regards
Artur Dorochowicz