1

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

abrfra
  • 634
  • 2
  • 6
  • 24
  • 1
    You need to provide further details on what you wish to achieve. I don't think anyone needs to access any reference there is from within the container itself when using DI properly, as the container shan't be accessed from within your code. The only location where you can access the container is within the Composition Root itself. Other than that, use the dependencies provided by the container only. – Will Marcouiller Sep 22 '14 at 15:15

1 Answers1

3

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.

Matías Fidemraizer
  • 63,804
  • 18
  • 124
  • 206