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

查看:65
本文介绍了如何使用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 出现故障,则可以放松.很有可能是OS不会回收新释放的内存(因为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天全站免登陆