Memory Leak when "de attaching" Action

Topics: Actions & Coroutines, Bugs
Jun 20, 2013 at 2:11 PM
Hi everyone

We have a few UI elements (Infragistics Ribbon Controls) where we wire Actions not by XAML but by code. We want to wire the action only temporarily.
What we do is:
Action.SetTarget(this.buttonTool, someObject);
Message.SetAttach(this.buttonTool, "SomeName");
and later we unwire it using
Action.SetTarget(this.buttonTool, null);
Message.SetAttach(this.buttonTool, "SomeName");
(i realize the second call to Message.SetAttach is superfluous).

This may be repeated for the same UI Element.

Now someObject is never garbage collected. We don't keep any references to someObject. We keep a reference to this.buttonTool.

So, to investigate, we created an IntermediaryObject whose lifecycle is 1:1 to this.buttonTool.
Now we use Message.SetAttach / Action.SetTarget on the IntermediaryObject. IntermediaryObject has a (temporary) reference to someObject. As soon as the reference to someObject is removed from IntermediaryObject, someObject gets garbage collected.

Disclaimer: I'm not convinced that this is an issue with Caliburn.Micro, it could just as well be an issue with the Infragistics Controls.

However, i find myself a bit lost in terms of finding the cause.
Can you give me any pointers on where i could look next?
Is using Action.SetTarget(...,null) correct for de-attaching an action?

We are using Caliburn.Micro.1.5.1

Thank you for your time.

Regards,
Bruno Juchli
Jun 20, 2013 at 4:51 PM
Seems to be similar to https://caliburnmicro.codeplex.com/workitem/320
Updating to Caliburn.Micro 1.5.2 should fix the problem.
Jun 21, 2013 at 7:08 AM
Edited Jun 21, 2013 at 10:36 AM
Well thank you. That it is very nice to hear. I've checked the Issues page but didn't find anything related. But maybe i was just beeing to stupid ;-)
Will give it a try ASAP.

EDIT: i only checked basic view and since it's a closed issue i didn't see it. Got to remember that for next time :)