Problem with Signals , RL and Garbage Collection between a shared context.

Adam's Avatar

Adam

21 Apr, 2011 07:43 PM

Hello All,

I've been working for a while with Robotlegs , most recently in conjuction with a multi module flex project. We have one application that essentially functions as a harness , or bootstrap for modules compiled against a common lib.When the modules load we essentially share the context , application domain via a command , so the module's injector is actually the parent's. This works great. We decided recenrtly to roll as3-signals as it seemed to gained fairly wide support from other RL users , and , we feel its a bit cleaner than solely using events over the context bus. At any rate , all was well , until we noticed that upon loading and unloading the module , signals were not properly being re created. In fact , they were never actually being disposed of at all , despite unmapping them from the signal command map. I believe this to be a result of the way swift supsenders maintains its lookups / dictionaries. We did extensive profiling and were unable to get this working by unmapping them from the signal command map directly. However , i found that instead of doing this :

signalCommandMap.mapSignalClass(SomeSignal, SomeCommand);

if you do :

var someSignal:SomeSignal= new SomeSignal(); injector.mapValue(SomeSignal, someSignal); signalCommandMap.mapSignal(someSignal, SomeCommand);

when we subsequently call signalCommanMap.unmap and injector.unmap, the objects get correctly disposed of.

Hope this helps someone having the same problem. Keep up the great work RL team.

  1. Support Staff 1 Posted by Stray on 29 Apr, 2011 04:55 PM

    Stray's Avatar

    Thanks Adam, if Joel hasn't already knocked this off the to-do list, I'll make sure it gets done in the next week or so - and thanks for the work-around in the meantime.

    Stray

  2. Support Staff 2 Posted by Stray on 02 May, 2011 12:44 PM

    Stray's Avatar

    Hi Adam, just to follow up on this, we need to have a bigger think about how clean-up happens with utilities that make use of the injector.

    It's important that the SignalCommandMap keeps the same instance when you unmap / remap Signals to Commands, because there may be other objects - Models, Services, Mediators - which have been injected with this instance, and we need to make sure that one is the one that is used in future too.

    I think most likely the best work around is going to be the one you've found - that you need to manage certain kinds of instances manually, because only the developer knows whether this instance really should be cleaned up now or whether you'd like it to persist because it's still useful in other objects / contexts etc.

    So - thanks for the info - it's good to have a sensible solution for others to implement.

    We're going to be looking hard at how utilities integrate with robotlegs (especially with the Injector) in the near future as we start to think (slowly) about Robotlegs 2, so this is a great example for us to study.

    Cheers,

    Stray

  3. Stray closed this discussion on 02 May, 2011 03:36 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac