Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Fix memory leaks #110

Merged
merged 2 commits into from
Sep 19, 2016
Merged

Fix memory leaks #110

merged 2 commits into from
Sep 19, 2016

Conversation

eirikurn
Copy link
Contributor

@eirikurn eirikurn commented Jul 3, 2016

Without jQuery, velocity implements it's own $.data() utility which
stores element (animation) data in one big cache object.

Data in this cache is never cleared which is an issue because it keeps
references to all animated dom elements as well as whole React trees
through velocity-react's complete handler.

This commit crudely clears the most important velocity data when an
animated component is unmounted.

See julianshapiro/velocity#644

Otherwise, this leak causes constant crashes for non-trivial webapps on mobile devices.

Without jQuery, velocity implements it's own .data() utilities which
store element (animation) data in one big cache.

Data in this cache is never cleared which is an issue because it keeps
references to all animated dom elements as well as whole React trees
through velocity-react's `complete` handler.

This commit crudely clears the most important velocity data when an
animated component is unmounted.

See julianshapiro/velocity#644
@eirikurn
Copy link
Contributor Author

eirikurn commented Jul 3, 2016

Also, sorry for the lightning PR before any issue discussion.

I just hammered this fix out because the issue is critical in our project. We're running on a fork so I'm happy to close this PR if you want to look into other solutions.

@iSimonWeb
Copy link

👍 up

@fionawhim
Copy link
Collaborator

Cool. This seems reasonable. I think this also safe server-side since componentWillUnmount isn't called then.

Heads up, @kenwheeler, it might be nicer to have a Velocity helper for clearing this data rather than duplicating the ['velocity', 'fxqueue'] keys in this code.

@fionawhim
Copy link
Collaborator

I'd like to merge this, I just need to validate that it's also fine when jQuery is installed.

@morajabi
Copy link

Any news?

@fionawhim
Copy link
Collaborator

Demo still seems to work with this, so I think it's safe.

@fionawhim fionawhim merged commit 5a55b7f into google-fabric:master Sep 19, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants