Jump to content
Search Community

timelinelite memory leak unloading external swfs [SOLVED]

doodledude test
Moderator Tag

Recommended Posts

Hi, I have a main (application) swf which loads and unloads pages (other swfs).

each load/unload has a page transition.

 

where i use:

public function transitionOut():void{
var time:Number=1.1;
TweenLite.to(this, time, {x:1000, alpha:0, onComplete:transitionOutComplete})
}

everything works as expected

 

however i need to be able to use TimelineLite/Max for more complex sequences

so, if i swap the code above for:

private var _pageTweener:TimelineLite;
//---------
public function transitionOut():void{
var time:Number=1.1;
_pageTweener = new TimelineLite({onComplete:transitionOutComplete});
_pageTweener.insert(TweenLite.to(this, time, {x:1000, alpha:0}));
}

now, if i'm patient and let the transition timeline complete everything again is as expected.

however should i try to remove a page before the timeline completes the whole page gets trapped in memory.

 

to explain further the situation is when another page load happens mid-transition ie. user clicking rapidly and a page loads from cache.

at which point i dispose of the oldest page to make room for the newer page.

this memory leak does not happen at all where i just use tweens without the timeline.

 

i am very careful not to tie anything down and each page calls a dispose function to clear itself ready for garbage collection before unload.

here is everything i call to try and clear the timelinelite:

try{_pageTweener.stop()}catch(e:*){};
try{_pageTweener.killTweensOf(this);}catch(e:*){};
try{_pageTweener.clear();}catch(e:*){};
try{_pageTweener.invalidate();}catch(e:*){};
try{_pageTweener.kill();}catch(e:*){};
try{_pageTweener.vars.onComplete=null;}catch(e:*){}
_pageTweener = null;

 

it seems as though timelinelite is not clearing all references/listeners immedialty when i try to dispose of it.

 

any ideas?

Link to comment
Share on other sites

Aha! I believe I have solved it. There were two issues - one was in your code and one was in the GreenSock code. Your code used the same variable for both the transitionIn() and transitionOut() TimelineLite instances, so one was orphaned in the scenario where it animates in and before it finishes, transitionOut() gets called. Then on the destroy() call, it would kill() the last TimelineLite instance (the out one) but not the first.

 

There was also an adjustment I needed to make in SimpleTimeline and TimelineLite to prevent a very particular (rare) gc issue. I've posted an update of the classes, so please download the latest version from http://www.TweenLite.com and run your test again (after you adjust your code as well) - I think you'll see that there are no gc issues.

 

Thanks for bringing this to my attention.

 

Oh, and by the way, you should only need to kill() the TimelineLite and null your variable - no need to killTweensOf(), invalidate(), clear(), etc. :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...