How to unload a ByteArray using Actionscript 3?

前端 未结 8 2399
感动是毒
感动是毒 2020-12-30 18:32

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

I have tried the following:

// First non-working solution
byteA         


        
8条回答
  •  醉话见心
    2020-12-30 18:52

    Unfortunately when it comes to memory management in Flash/actionscript there isn't a whole lot you can do. ActionScript was designed to be easy to use (so they didn't want people to have to worry about memory management)

    The following is a workaround, instead of creating a ByteArray variable try this.

    var byteObject:Object = new Object();
    
    byteObject.byteArray = new ByteArray();
    
    ...
    
    //Then when you are finished delete the variable from byteObject
    delete byteObject.byteArray;
    

    Where byteArray is a dynamic property of byteObject, you can free the memory that was allocated for it.

提交回复
热议问题