tconkling / flump

Exports Flash .FLAs to GPU-friendly formats
MIT License
381 stars 70 forks source link

Memory leaks. With ATF textures and with AS structures. #126

Closed tikislabmax closed 9 years ago

tikislabmax commented 10 years ago

When I'm using flump with starling there is something that looks like memleak. I'm loading JSONzip (with MovieLoader). Archive is about 8M and contains 7 ATF (ETC1) textures 26M in total.

and after that I can see in Scout that after decompressing and loading textures into GPU, there is 33M of raw byteArray data left. And it never garbage collected. If I will load new libraries - there will be allocations and releases but still 33M left in memory and never disappear.

Testapp actually does nothing else but loads the flump's archive.

I've tried just load textures into app directly - this does not happen - byteArray memory remains empty. Looks like content of the files remains in memory somewhy.

I've tried to clear zipfile contents at the end of Loader.onFileLoaded method but then textures never appear in the library.

P.S. would be much easier if you'd allow passing zip and loading textures and JSON file directly. I'd like to customize Loader class, but can't figure out what class handles

_libLoader.atfAtlasLoaded.emit({name: name, bytes: loaded.content}); in Loader.onFileLoaded method

maybe you can give me a clue? I actually simply need to pass preloaded JSON and links to preloaded atlases to the library or some movie creator. This thing with signals is too complicated for me :)

tikislabmax commented 10 years ago

Problem appears in android and desktop (windows) runtimes when I use ATF instead of png.

Seems the Loader.loadAtlas method is in trouble.

I've removed the leak when added at the end of the method

//ANTILEAK
ByteArray(_atlasBytes[atlas.file]).clear();
delete _atlasBytes[atlas.file];

Still there is another leak in the Actionscript objects - seems it is a Movie class (probably because it cross referenced with its layers). I've been loading (load, create movie, add to displaylist) and unloading .zip (kill library, kill movie, remove from displaylist and Juggler) - and there still remains big objects waste GC can't handle. (about 500kb each iteration).

here is a link to the Scout files http://tikislab.com/testarea/tmp/flump_memleak.rar

link to the .zip I'm using http://tikislab.com/testarea/tmp/sis_passage_dxt.zip

Loading:

private var movie:Movie;
private var lib:Library;

private function loadScene():void {
            var libloader:LibraryLoader = new LibraryLoader();
            const loader:Future = libloader.loadURL("sis_passage.zip");
            loader.succeeded.connect(onLibraryLoaded);
        }

protected function onLibraryLoaded (library :Library) :void {   
    lib = library;
    movie = lib.createMovie("mc_graphics");
    sceneSprite.addChild(movie);
    Starling.juggler.add(movie);
}

Unloading:

private function disposelib():void {
            Starling.juggler.remove(movie);
            sceneSprite.removeChild(movie);
            movie.dispose();
            movie = null;
            lib.dispose();
            lib = null;
        }

P.S. shoul I create separate issues for this?