Does Castle Windsor keep a reference of resolved object with lifestyle transient?

1.8k Views Asked by At

If castle keep a reference to that object, where can i access to that? There is a list of that reference somewhere inside the container?

I'm using Castle Windsor 3.3.0

1

There are 1 best solutions below

2
On BEST ANSWER

If castle keep a reference to that object, where can i access to that?

It has a reference to manage object's life. You don't need this reference and you shouldn't manage references created by encapsulated code (this is about object-oriented programming encapsulation and abstraction principles!).

You need to release a manually resolved component even if this is transient in order to let Castle Windsor discard that reference and garbage collector free up memory.

Check the following statement taken from official documentation:

Some people, especially those who used certain other containers in the past, sometimes forget that Windsor may track transient components. They Resolve the instances, and never Release them. To ensure proper components lifecycle management Windsor may track those components. That means that unless you release them, Garbage Collector will not be able to reclaim them, and you'll end up with de-facto memory leak. So remember this useful rule of thumb: Remember to Release what you explicitly Resolved.