Weak references in html5

Do weak references work in html5? Originally I was trying to track down some memory leaks with a Dictionary with weak keys (this has helped me with openfl .swf files) but I can’t get anything to ever be removed from the dictionary.

I set up a test. I expect the console output to be full of ‘hello’ messages until I press a key to instantiate 100000 Sprites and trigger GC. Flash operates as expected, but html5 never stops tracing ‘hello’. Using the Chrome Dev Tools to trigger GC also doesn’t stop the traces.

package;


import openfl.Assets;
import openfl.Lib;
import openfl.display.Sprite;
import openfl.events.Event;
import openfl.events.KeyboardEvent;


class Main extends Sprite {
	
	public function new () {
		super ();
        Lib.current.stage.addEventListener(KeyboardEvent.KEY_DOWN, makeGarbage);        
        new Sprite().addEventListener(Event.ENTER_FRAME, sayHello, false, 0, true); //weak reference
	}
	
	public function makeGarbage(e : KeyboardEvent= null)
	{        
        for (i in 0...100000)
        {
            var temp = new Sprite();
        }		
		trace( "-------------------- MADE SOME GARBAGE -------------------" );	
	}

    function sayHello (e : Event) : Void
    {
        trace('hello ' + e.currentTarget);
    }
}

The Dictionary with weak keys concept I tried is based on this: https://divillysausages.com/2011/04/10/tracking-memory-leaks-in-as3/ (which did work for me when exporting to flash)

That said, we may be able to help remedy this in the future:

However, the C++ WeakMap implementation in HXCPP will need additional work to be production-worthy. I had trouble with it before