Skip to search.
nservicebus

Group Information

  • Members: 1298
  • Category: Software
  • Founded: Dec 16, 2007
  • Language: English
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Messages

  Messages Help
Advanced
NServiceBus + Castle Windsor = memory leaks ?   Message List  
Reply Message #5376 of 14127 |

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



Thu Jan 28, 2010 7:53 pm

artur@...
Send Email Send Email

Message #5376 of 14127 |
Expand Messages Author Sort by Date

Hello, It is a bit unknown fact that Windsor keeps references to resolved components and that they should be "released" via IWindsorContainer.Release() call...
Artur Dorochowicz
artur@... Send Email
Jan 28, 2010
7:53 pm

Artur, Thanks for the heads up, added this line of code to the Castle Windsor builder (after consulting Ayende): container.Kernel.ReleasePolicy = new...
Udi Dahan
udidahan7 Offline Send Email
Jan 28, 2010
9:20 pm

Well, if Ayende says it's fine then it's probably fine ;) I was kind of expecting that you would come up with this solution and not go with a design change. My...
Artur Dorochowicz
artur@... Send Email
Jan 28, 2010
10:17 pm

well, that makes sure that Windsor will not hold references to resolved components, but it also means that it won't automatically dispose disposable transient...
Davy Brion
ralinx@... Send Email
Jan 29, 2010
6:15 am

... dependencies of resolved components anymore If it no longer holds a reference to a message handler, then the handler will be collected by the GC. If the...
Udi Dahan
udidahan7 Offline Send Email
Jan 29, 2010
7:14 am

well yeah, it will be garbage collected, but the whole point of using IDisposable is for those situations where you don't _want_ to wait around for the GC to...
Davy Brion
ralinx@... Send Email
Jan 29, 2010
7:56 am

... No the key point is release of unmanaged resources which isn't picked up by the GC. --...
Werner
wernerclausen Offline Send Email
Jan 29, 2010
8:54 am

not necessarilly i have a UnitOfWork implementation which requires being disposed to properly clean up the NHibernate session... i'm pretty sure i'm not the...
Davy Brion
ralinx@... Send Email
Jan 29, 2010
9:01 am

It doesnt change its primary intent. In fact, you should leave as much as possible to the GC, unless you have some business reason not to do so. Thats one of...
Werner
wernerclausen Offline Send Email
Jan 29, 2010
9:14 am

Units of work should be managed by message modules for deterministic cleanup. See the NHibernateMessageModule that comes with NServiceBus as an example. -- Udi...
Udi Dahan
udidahan7 Offline Send Email
Jan 29, 2010
11:55 am

After seeing Davy Brion's response, I must say I'm completely with Davy on this one. By changing the release policy you change the default behaviour which...
Artur Dorochowicz
artur@... Send Email
Jan 30, 2010
10:08 am

Artur, I respectfully disagree with Jeremie's design philosophy. With respect to changing default Windsor behaviors, that is part of container abstraction -...
Udi Dahan
udidahan7 Offline Send Email
Jan 30, 2010
11:49 am
Advanced

Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines NEW - Help