且构网

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

Adobe AIR - 垃圾收集和 system.gc()

更新时间:2023-12-03 19:08:04

system.gc 是 AIR 和 Flash 播放器中的仅调试功能.我认为***的办法是回收位图数据和其他对象,如果可以避免 gc,如果不能,请在使用完后立即调用 bitmapdata.dispose() 和 bitmapdata = null.

system.gc is a debug only functionality in AIR and Flash player. I think the better thing is to recycle bitmapdata and other objects if you can to avoid gc, and if not call bitmapdata.dispose() and bitmapdata = null as soon as you are done with using them.

如果您的项目中在不同时间有相同大小的位图对象,您可以使用 BitmapData 的同一个实例对它们进行操作.这类似于 ItemRenderers 回收项目的方式,或者甚至其他平台(如 iOS 的 UITableViewController 回收/重用 UITableViewCell 的方式).垃圾回收不是灵丹妙药,应该在简单的可编程性比性能更重要时使用.

If you have bitmap objects of the same size at various times in your project, you can use the same instance of BitmapData to operate on them. This is similar to how ItemRenderers recycle items or how even other platforms like iOS's UITableViewController recycles/reuses UITableViewCell. Garbage collection is not panacea, it should be used when easy programmability is more important than performance.