This is not true, at least in the current version of Flash.
I created a function that creates a large string, creates a closure by referencing it, and then calls setTimeout with the closure.
public function tick():void { var data:String = "helloworld"; for (var j = 0; j < 20; j++) { data += data; } var f = function() { var i = 0; if (data.length > 0) { i++; } }; setTimeout(f, 0); }
I used this feature very often and used System.totalMemory (as well as the OS X activity monitor) to monitor flash usage.
function Main():void { setInterval(tick, 10); setInterval(display, 500); } public function display():void { trace("Memory usage: " + System.totalMemory + "B."); }
Memory usage would not last long, but would then fall down when the garbage collector jumped. Average memory usage was stable for several minutes.
When I changed the code to keep a clear link to each close 1 memory usage increased to a few gigabytes in a couple of minutes. The documentation is out of date. Flash does not support closure references passed to setTimeout . (At least on OS X, I assume this will be the same on Windows.)
1 I created the array as a static class var and push ed each f on it before calling setTimeout .Sub>
source share