有人知道是否可以将垃圾回收应用于AS3中的新StageVideo组件吗?我试过了,但没有成功!代码如下:
if ( this._stageVideo == null )
{
this._stageVideo = stage.stageVideos[0];
this._stageVideo.addEventListener(StageVideoEvent.RENDER_STATE, stageVideoStateChange);
}尝试GC:
this._stageVideo = null;
this._stageVideo.removeEventListener(StageVideoEvent.RENDER_STATE, stageVideoStateChange);发布于 2011-10-07 21:28:56
this._stageVideo = null;
this._stageVideo.removeEventListener(StageVideoEvent.RENDER_STATE, stageVideoStateChange)我很惊讶它能工作,它应该抛出一个异常,你应该首先删除事件侦听器,然后使它的引用无效。
垃圾收集器不会在您每次将某些东西置为空时启动,但如果您可以使用Flash Builder分析器,您可以尝试强制GC,而且如果您想测试它,您可以将项目打包为AIR,并手动调用GC。
如果两次启动LocalConnection失败(http://www.nbilyk.com/flash-garbage-collection),有一个bug/功能会调用GC:
try {
new LocalConnection().connect('foo');
new LocalConnection().connect('foo');
} catch (e:Error) {}https://stackoverflow.com/questions/7685755
复制相似问题