0

I am currently using arthur-debert's BulkLoader in My Project, as I need to load a list of SWF and display them on screen. However, once I try to dispose the BulkLoader instance and reload another list, problem occurs: There is a lot of memory cached.

To investigate the correct method to dispose those resources, I've done a little research. I 've tried loader.removeAll(), loader.clear(), loader.getContent("XXX", true), and Bulkloader.removeAllLoader() But none of them can help.

Here is my test's code:

public static var file:XML;  *// this will store s list of path of different SWF*
private var loader:BulkLoader = new BulkLoader();
private var count:int = 0;
private var NumberOfTest:int = 20;
private function Test3():void
{
    for (var i:int = 0; i < file.item.length(); i++)
    {
        loader.add("ui/" + String(file.item[i].@url));
    }
    loader.addEventListener(BulkProgressEvent.COMPLETE, OnComplete, false, 0, true);
    loader.start();
}

private function OnComplete(e:BulkProgressEvent):void
{
    loader.removeEventListener(BulkProgressEvent.COMPLETE, OnComplete, false);
    loader.clear();
    loader = new BulkLoader();
    System.gc();

    if (count < NumberOfTest)
    {
        trace("Finish Count : " + count);
        count++;
        Test3();
    }
    else
    {
        trace("Finish All Test");
    }
}

After the above test, I suppose the memory usage should return to the level before the test. But the result is different from my expectation. Here is My Result:

Before the test:
    Current Total Memory: 101,471 KB
    Used Memory: 98,524
    ActionScript Objects: 25,425
    Bitmap DisplayObjects: 32,988
    Bitmap Filter Buffer: 58
    CacheAsBitmap Buffers: 39
    Main Screen Buffer: 2,344
    Other Bitmap Memory: 90
    ByteArrays: 0
    SWF Files: 21,028
    Network Buffers: 128
    Uncategorized: 16,424

After the test:
    Current Total Memory: 378,559 KB
    Used Memory: 344,978
    ActionScript Objects: 121,171
    Bitmap DisplayObjects: 32,988
    BitmapFilter Buffers: 58
    CacheAsBitmap Buffers: 39
    Main Screen Buffer: 2,344
    Other Bitmap Memory: 119
    ByteArrays: 0
    SWF Files: 102,263
    Network Buffers: 128
    Uncategorized: 85,868

And Those Overshoot Cannot be GC no matter loader.removeAll(), loader.clear(), loader.getContent("XXX", true), and Bulkloader.removeAllLoader(). Can Someone has experience about how to deal with this problem?

Jacky Lau
  • 665
  • 5
  • 21
  • Have you tried this with debugging turned on? Calling the garbage collector manually only works when the swf is published with debugging true. Also, in the OnComplete handler you should set loader = null, not create a new instance of BulkLoader. – Scott Sep 25 '14 at 23:31
  • Somethings wrong with my files, which were going to be loaded. – Jacky Lau Dec 15 '14 at 03:12

0 Answers0