How to unload a ByteArray using Actionscript 3?

前端 未结 8 2406
感动是毒
感动是毒 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:35

    Have a look at this article

    http://www.gskinner.com/blog/archives/2006/06/as3_resource_ma.html

    IANA actionscript programmer, however the feeling I'm getting is that, because the garbage collector might not run when you want it to.

    Hence http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/

    So I'd recommend trying out their collection code and see if it helps

    private var gcCount:int;
    private function startGCCycle():void{
        gcCount = 0;
        addEventListener(Event.ENTER_FRAME, doGC);
    }
    private function doGC(evt:Event):void{
        flash.system.System.gc();
        if(++gcCount > 1){
            removeEventListener(Event.ENTER_FRAME, doGC);
            setTimeout(lastGC, 40);
        }
    }
    private function lastGC():void{
        flash.system.System.gc();
    }
    

提交回复
热议问题