Unloading a ByteArray using Actionscript 3

2019-02-11 09:51发布

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

I have tried the following:

// 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;
}

8条回答
ら.Afraid
2楼-- · 2019-02-11 10:23

I believe you have answered your own question...

System.totalMemory gives you the total amount of memory being "used", not allocated. It is accurate that your application may only be using 20mb, but it has 5mb that is free for future allocations.

I'm not sure if the Adobe docs would shed light on the way that it manages memory...

查看更多
\"骚年 ilove
3楼-- · 2019-02-11 10:24

So, if I load say 20MB from MySQL, in the Task Manager the RAM for the application goes up by about 25MB. Then when I close the connection and try to dispose the ByteArray, the RAM never frees up. However, if I use System.totalMemory, flash player shows that the memory is being released, which is not the case.

The player is "releasing" the memory. If you minimize the window and restore it you should see that the memeory is now much closer to what System.totalMemory shows.

You might also be interested in using FlexBuilder's profiling tools which can show you if you really have memory leaks.

查看更多
登录 后发表回答