removeCore doesn't stop the Notifier get facade from rebooting the Facade
Not sure what you mean by this. Facade.removeCore is a STATIC method, and does this:
public static function removeCore( key:String ) : void
{
if (instanceMap[ key ] == null) return;
Model.removeModel( key );
View.removeView( key );
Controller.removeController( key );
delete instanceMap[ key ];
}
Are you suggesting it should operate differently?
just removing the IPipeFitting from the pipesMap isn't enough, you have to disconnect the pipe.
That pipe, once removed from the pipesList is no longer referenced by anything other than the core you've just cut loose and the pipeline it's connected to. Like having a freshly removed sink with pipes sticking out of it, but not connected to your water / sewer lines sitting in your floor. Once it's no longer connected to anything it can be hauled away. Similarly, once there are no more
outside references to the module's facade, the module it is a part of, and the pipes that were connecting that module to the rest of the system, the whole core goes away. Simon Bailey has demonstrated this in his demo on garbage collection. (
http://www.nutrixinteractive.com/blog/?p=132)
BUT... GC does operate unpredictably in Flash (
http://gskinner.com/blog/archives/2008/04/failure_to_unlo.html).
Conceptually the existing mechanism is sound according to the rules of Flash GC. Even though the Pipe is connected to the Junction in the JunctionMediator in the View of the Module, if no references to the Module or the pipe exist, it is not necessary to disconnect the pipe. They are a cluster of entities that reference each other but are referenced from nowhere else in the VM, and therefore the entire cluster is eligible for GC. Disconnecting the pipe for good measure is not necessary.
Also consider the possibility that the pipe is connected to a filter which is then is connected to the module. Disconnecting the pipe leaves the rest of the apparatus hanging out there, and so would not be effective if it were really necessary to disconnect. You'd need to travel down the pipeline disconnecting each piece. But again, that should never be necessary. Two or more objects referencing each other apart from the rest of the program cannot keep each other from GC eligibility.
I think its extremely likely that during your debugging, you ran into some of the unpredictability of Flash GC and/or were holding references to the module or pieces of it elsewhere.
I've run Simon's GC Demo, loaded a module, sent a message from the shell to the module and from the module back to the shell to show they were plumbed properly. Then after unload, in this case, the memory size was exactly the same before and after.
However, if you run it a number of times, you'll see that the unpredictible behavior of GC crops up. Sometimes it's not the same. Sometimes less, sometimes more. Again check GSkinner's article describing why this is so, and read Simon's article to see what he went through to get this working. It is not possible to force GC to happen. You free things up and the GC gets around to cleaning up (or not) whenever it feels like it.
-=Cliff>