强制垃圾收集在AS3? [英] Force Garbage Collection in AS3?

查看:161
本文介绍了强制垃圾收集在AS3?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能以编程方式强制完整垃圾收集运行在ActionScript 3.0?

Is it possible to programmatically force a full garbage collection run in ActionScript 3.0?

比方说,我创建了一堆Display对象与EventListeners的和一些DO的已被删除,一些EventListeners的已被触发,删除等...有没有办法强制运行垃圾收集和收集一切可用于收集?

Let's say I've created a bunch of Display objects with eventListeners and some of the DO's have been removed, some of the eventListeners have been triggered and removed etc... Is there a way to force garbage collection to run and collect everything that is available to be collected?

推荐答案

是的,这是可能的,但它通常是一个坏主意。在GC应该有一个更好的主意的时候是一个很好的时间比你应该运行的,并且除了一个非常特殊的情况下,像你刚才使用的内存为500MB,你需要把它找回来尽快,你不应该叫GC你自己。

Yes, it's possible, but it is generally a bad idea. The GC should have a better idea of when is a good time to run than you should, and except for a very specific case, like you just used 500MB of memory and you need to get it back ASAP, you shouldn't call the GC yourself.

在Flash 10,有一个的System.gc()方法,你可以调用(但请别,见上文) - 记住的System.gc( )只能在调试版本的Flash播放器10+的。

In Flash 10, there is a System.gc() method you can call (but please don't, see above) - keep in mind System.gc() only works in the debugging version of Flash player 10+.

在Flash 9,存在不支持的方式,通过一个奇怪的LocalConnection命令强制它,但它可能无法在所有版本。请参见这篇文章格兰特斯金纳的。

In Flash 9, there is an unsupported way to force it via an odd LocalConnection command, but it may not work in all versions. See this post by Grant Skinner.

这篇关于强制垃圾收集在AS3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆