Jump to content
GreenSock

themepunch

Do we need to care about garbage collection ?

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

hi guys,

 

i have a slider where i build timelines based on the dynamic changes of the content and user actions.  

It can happen that the same timeline is not used any more, but it can happen that it reused later. 

 

However if the slider runs over a while, it can logically have a row of timelines defined somewhere in the memory.  I define timelines within a function locally, and give it for other local functions  to starting / stopping it on demand.  Once that happen, i lose focus of it.

 

The question basically if i should tidy up these timelines, or will it after the tweening just disappear after a while, freeing the resources ?

 

If not, how should i make sure that not unneeded resources are in use later ?

 

Thanks,

 

Krisztian from ThemePunch

Link to comment
Share on other sites

In general, no, you don't need to worry about GC with GSAP. It automatically does stuff under the hood to release things when appropriate. However, you should still use normal good practices, like don't maintain references to objects that you don't need anymore, which could be tweens or timelines or elements or whatever. GSAP cannot protect you from writing code that GC-proofs objects but the system itself handles its own GC management well.  

 

Definitely make sure you're using the latest version of GSAP, though. That's pretty much always a good idea. :)

  • Like 1
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.
×