Castle Windsor - Why would I not want to use 'NoTrackingReleasePolicy' as default?
Asked Answered
E

1

11

I come from the StructureMap world, where it is never necessary to release resolved transient objects.

I see that Windsor by defauly keeps track of any resolved transient objects and therefore prevents them from being garbage collected until they are released (if they ever are released).

I found NoTrackingReleasePolicy in the docs, but it's usage is discouraged.

Having to release any transient objects seems like going back in time to me.

I will use NoTrackingReleasePolicy in my app.

What trouble am I getting into by doing this? Or in other words why would I want to release objects manually instead of having the garbage collector handle that for me?

Eisteddfod answered 23/10, 2011 at 21:7 Comment(3)
I recommend reading devlicio.us/blogs/krzysztof_kozmic/archive/2010/08/27/… before taking any decision about this. In a nutshell: if you have to worry too much about this, you're using the container the wrong way (be it StructureMap, Windsor, or any other container).Microfilm
@Mauricio, thanks for the link. Was a very interesting read. In my case I am working from within the context of an asp.net mvc app, so it seems that I will not need to manually release any dependencies in the controllers. I wonder though how it will work with Wcf Web Api which we are also using heavily. I don't think that the service classes will autom. get released when the web request ends. Will have to investigate that.Eisteddfod
the WCF facility does that: github.com/castleproject/Windsor/tree/master/Facilities/… don't know about WebAPI specifically.Microfilm
B
4

Just so that question doesn't stay unanswered:

The matter is explained in the blogpost linked by @mauricio scheffer in the comments.

Basically using NoTrackingReleasePolicy is going to lead to a lot of subtle problems, and if you architect your app right, with the default release policy, you don't have to worry about calling release explicitly in your code anyway.

Biocatalyst answered 4/10, 2012 at 3:14 Comment(1)
Link is broken nowBenedetto

© 2022 - 2024 — McMap. All rights reserved.