violacase Posted May 12, 2021 Share Posted May 12, 2021 Since a new instance of SplitText is a 'new' object I wonder if Splittext.revert() not only clears the DOM but also the object itself from memory. If not how do I free the object itself? Link to comment Share on other sites More sharing options...
Cassie Posted May 12, 2021 Share Posted May 12, 2021 You shouldn't need to worry about garbage collection yourself. I may have to check with @GreenSock on the specifics but as far as I know GSAP releases animations a few seconds after they're done for GC. Link to comment Share on other sites More sharing options...
violacase Posted May 12, 2021 Author Share Posted May 12, 2021 @Cassie Thanks for so far. I really want to be certain. In my future (text fun) projects I think I have to create (and revert of course) many instances in a single page. 1 Link to comment Share on other sites More sharing options...
Cassie Posted May 12, 2021 Share Posted May 12, 2021 Over to Jack then. He'll be around soon. (We're on different time schedules) ☺️ 1 Link to comment Share on other sites More sharing options...
OSUblake Posted May 12, 2021 Share Posted May 12, 2021 9 hours ago, violacase said: If not how do I free the object itself? You have to remove any references to it. Not a gsap thing. That's just how programming works. let split = new SplitText(yourElement); // later split.revert(); split = null; 3 Link to comment Share on other sites More sharing options...
OSUblake Posted May 12, 2021 Share Posted May 12, 2021 9 hours ago, violacase said: If not how do I free the object itself? But don't get too hung about things like that. 1 split text object is not going to cause any issues. Maybe a million. 2 Link to comment Share on other sites More sharing options...
Solution OSUblake Posted May 12, 2021 Solution Share Posted May 12, 2021 9 minutes ago, OSUblake said: But don't get too hung about things like that. But if you want to be in the know, just search for how to avoid memory leaks in JavaScript. Here's a start... https://dev.to/kepta/a-toddlers-guide-to-memory-leaks-in-javascript-25lf 3 Link to comment Share on other sites More sharing options...
violacase Posted May 13, 2021 Author Share Posted May 13, 2021 Many thanks @OSUblake! And a big hug for explaining just a bit more then my question was about initial 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now