Can You Come Up With A WHY Comment For This Code?

5 commentsWritten on February 18th, 2010 by
Categories: Memory Management

I just had to write the following code:

    public class MyReleasePolicy : Castle.MicroKernel.Releasers.LifecycledComponentsReleasePolicy

    {

        public override void Track(object instance, Castle.MicroKernel.Burden burden)

        {

            if (!instance.GetType().FullName.StartsWith("NServiceBus"))

            {

                base.Track(instance, burden);

            }

        }

    }

 

and then this:

            IoC.Container.Kernel.ReleasePolicy = new MyReleasePolicy();

 

to make a problem go away.

Can you come up with a WHY comment? (the category of this post is another hint)

  • http://simon-says-architecture.com/ Szymon Pobiega

    Yeah I can, but I think this would be cheating;-)

  • http://davybrion.com Davy Brion

    did you run into the same issue or are you talking about this hack when you say ‘cheating’? (which i’d certainly agree with :p)

  • http://kozmic.pl Krzysztof Koźmic

    That’s interesting.
    I don’t know NServiceBus, but I would guess it somehow either takes care of managing its own dependencies, or for some reason is incompatible with Windsor’s life-cycle management.

    Do you plan a follow up post detailing the issue you’re working around here?

  • http://davybrion.com Davy Brion

    @Krzysztof

    “Do you plan a follow up post detailing the issue you’re working around here?”

    by now you should know me well enough to know the answer to that question :)

  • http://simon-says-architecture.com/ Szymon Pobiega

    I mean I know NSB’s ObjectBuilder from the inside and I am aware of this leak in it’s abstraction system — its dependency resolver abstraction has no notion of releasing components. Btw, it is Krzysztof who first turned my attention to this issue, in context of MetaContainer:)