Does anyone know if it's possible to apply garbage collection to the new StageVideo component in AS3? I have tried with no success! Code is below:
if ( this._stageVideo == null )
{
this._stageVideo = stage.stageVideos[0];
this._stageVideo.addEventListener(StageVideoEvent.RENDER_STATE, stageVideoStateChange);
}
Attempt at GC:
this._stageVideo = null;
this._stageVideo.removeEventListener(StageVideoEvent.RENDER_STATE, stageVideoStateChange);
I'm surprised that it worked, it should throw an exception, you should first remove event listeners and then nullify it's reference.
Garbage collector does not start every time you nullify something, but if you can use Flash Builder profiler you can attempt to force GC, also if you want to test it out, you can package project as AIR, and call GC manually.
There is bug/feature that will invoke GC if you fail to start LocalConnection twice (http://www.nbilyk.com/flash-garbage-collection):