SignalCommand garbage collection
I have CreateLevel command which is mapped as
signalCommandMap.mapSignalClass(CreateLevelSignal, CreateLevelCommand);
It creates a VOLevel object and sends it with - StartLevelSignal
signalCommandMap.mapSignalClass(StartLevelSignal, StartLevelCommand);
In RenderGameMediator i have alistener that does NOTHING
[Inject] public var startLevelSignal :StartLevelSignal;
startLevelSignal.add(startLevel);
private function startLevel( level:VOLevel ):void
{
//nothing here
}
After startLevel function I need GarbageCollector to clean VOLevel.
But in in SwiftSuspenderInjector I have a strong refference to VOLevel object that keep it from GC.
How to get rif of that refference(see attached pic)
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
1 Posted by havarez on 09 Nov, 2010 03:36 PM
here is a pic
2 Posted by ZackPierce on 09 Nov, 2010 07:38 PM
Bad news. At this point, the SwiftSuspenders Injector class has no way of directly releasing individual object references.
Good news. You can, however, use the
IInjector#unmap
method to remove all mappings for a given class.More bad news. The
SignalCommandMap
uses a child injector of the main injector, so you can't directly callinjector.unmap(VOLevel)
on the mainIInjector
instance in yourContext
.Solution: Hack your version of Robotlegs/SignalCommandMap.
signalCommandMap.injector.unmap(VOLevel)
when you're ready to prepare for garbage collection.3 Posted by havarez on 10 Nov, 2010 10:45 AM
I added getter for
Injector
property but...How to get signalCommandMap instance in my Mediator
to instantiate SignalCommandMap i need IInjector arg to pass.
Or should I inject SignalCommandMap?
Can I create command that will listen for
ClearObject
signal that has an object(as arg) needs to be unmaped for GC? (what would be the code?)Sorry if my questions sound stupid, first time working with DI ... little confused
4 Posted by havarez on 10 Nov, 2010 11:00 AM
I get error -
Error: Error while removing an injector mapping: No mapping defined for class com.flashracingonline.gloomytruck.model.vo::VOLevel, named ""
5 Posted by ZackPierce on 10 Nov, 2010 04:21 PM
You need to inject
SignalCommandMap
into your mediator, not reinstantiate it. If, like in the previous post, you make a totally newSignalCommandMap
out of thin air, it won't have any relevance to your existing mappings. If you use injection, then the injector will provide a reference to your existingSignalCommandMap
instance, which should include any mappings you've made at that point.Not without some more serious modifications to both Robotlegs and SwiftSuspenders. The the
injector.unmap
call I'm suggesting is only a work-around that is supposed to operate on whole Class-based mappings, not individual object instances.You could, however, make a
ClearClassMappingCommand
command, but it would really just be very simple wrapper aroundinjector.unmap
. You'd also have to go to the hassle of re-mapping that Class if you wanted to inject an instance of it somewhere later.6 Posted by Havarez on 11 Nov, 2010 03:37 PM
Thank yo very much! All works.
Stray closed this discussion on 10 Feb, 2011 06:11 PM.