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