Adobe AIR的 - 垃圾回收和System.gc()的 [英] Adobe AIR - Garbage collection and system.gc()

查看:161
本文介绍了Adobe AIR的 - 垃圾回收和System.gc()的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要建一个Adobe AIR的桌面应用程序使用Flash CS5,使大量使用的BitmapData,ByteArray对象和BASE64字符串。过了一会儿,该应用程序的内存使用量增加一倍。

I'm building an Adobe AIR desktop app with Flash CS5 that makes a lot of use of bitmapdata, bytearrays and base64 strings. After a while the memory usage of the app doubles.

时,则建议使用的System.gc()以释放内存在这一点上还是坏的做法?

Is it recommended to use system.gc() to free memory at that point or is that bad practice?

感谢。

推荐答案

的System.gc是一个调试AIR和Flash播放器唯一的功能。我认为更好的事情是,如果你能避免GC回收的BitmapData和其他物体,如果没有调用bitmapdata.dispose()和的BitmapData =只要你完成了使用它们。空

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的同一个实例来操作它们。这是类似的itemRenderer如何回收利用项目或怎么连其他平台如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.

这篇关于Adobe AIR的 - 垃圾回收和System.gc()的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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