如何使用 Actionscript 3 卸载 ByteArray? [英] How to unload a ByteArray using Actionscript 3?

查看:31
本文介绍了如何使用 Actionscript 3 卸载 ByteArray?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 ActionScript 3 从内存中强制卸载 ByteArray?

How do I forcefully unload a ByteArray from memory using ActionScript 3?

我尝试了以下方法:

// First non-working solution
byteArray.length = 0;
byteArray = new ByteArray();

// Second non-working solution
for ( var i:int=0; i < byteArray.length; i++ ) {
    byteArray[i] = null;
}

推荐答案

我认为您没有什么可担心的.如果 System.totalMemory 出现故障,您可以放松.很可能是操作系统没有回收新释放的内存(预计下次 Flash Player 会要求更多内存).

I don't think you have anything to worry about. If System.totalMemory goes down you can relax. It may very well be the OS that doesn't reclaim the newly freed memory (in anticipation of the next time Flash Player will ask for more memory).

尝试执行其他占用大量内存的操作,我相信您会注意到分配给 Flash Player 的内存会减少并用于其他进程.

Try doing something else that is very memory intensive and I'm sure that you'll notice that the memory allocated to Flash Player will decrease and be used for the other process instead.

据我所知,从查看分配给每个进程的数量,甚至分配的总量的角度来看,现代操作系统中的内存管理并不直观.

As I've understood it, memory management in modern OS's isn't intuitive from the perspective of looking at the amounts allocated to each process, or even the total amount allocated.

当我使用我的 Mac 5 分钟时,我的 3 GB RAM 的 95% 被使用,并且它将保持这种状态,它永远不会下降.这就是操作系统处理内存的方式.

When I've used my Mac for 5 minutes 95% of my 3 GB RAM is used, and it will stay that way, it never goes down. That's just the way the OS handles memory.

只要其他地方不需要它,即使已退出的进程仍然有分配给它们的内存(例如,这可以使它们下次启动得更快).

As long as it's not needed elsewhere even processes that have quit still have memory assigned to them (this can make them launch quicker the next time, for example).

这篇关于如何使用 Actionscript 3 卸载 ByteArray?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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