且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

强制垃圾收集在AS3?

更新时间:2023-11-22 22:36:22

是的,这是可能的,但它通常是一个坏主意。在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.