massiveinteractive/minject — pull request #3 by mikestead (2013-02-05 03:17:25+00:00)
Title: Avoid Storing Strong References to Injectees

Currently Injector.attendedToInjectees is a Dictionary of objects which have had their dependencies injected. This dictionary was created using strong instead of weak keys meaning that under flash/nme the injectees where never been GCd even when no longer referenced anywhere else.

This fix ensures weak references are used under flash/nme and that under dynamic languages like neko, as2 and js we never store a direct reference to the injectee, instead we add a hidden property to it to mark it as previously injected.

I've started to look at our Dictionary class using WeakRefs under cpp but have an [open question](https://groups.google.com/forum/#!topic/haxelang/EUKc40vG-S4) about that so won't make those changes now.

I've not been able to write a test to prove the GCing under flash as it appears that even when forced the GC needs to not have the enclosing function in scope before it will release the weak reference. That said, I have tested it out on an app and it does indeed remove the reference. I've also tested the JS version out on an app and it also now allows the GC of injectees no longer referenced (what caused me to investigate this in the first place).

Technically [this fix under mmvc](https://github.com/massiveinteractive/mmvc/pull/3) is no longer needed, but I don't think it hurts keeping it around.