Skip to content

Commit

Permalink
Animated JS: clear out component refs on unmount
Browse files Browse the repository at this point in the history
Summary:
"The instance should not stick around after unmount..." - Tim Yung, 2021

I have a hypothesis that, if a component instance of an animated component sticks around after unmount, it could cause memory leaks due to references to Fabric ShadowNodes across the JSI (this would not impact non-Fabric... in theory).

Wild guess. If OOMs disappear then maybe this hypothesis is correct, but it's a long shot. I figure there's ~no harm in doing this cleanup here anyway.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D26650348

fbshipit-source-id: 90633db650b65755cacfb52344e7b53e46c9b125
  • Loading branch information
JoshuaGross authored and facebook-github-bot committed Feb 25, 2021
1 parent 3e06af9 commit 468bc62
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Libraries/Animated/createAnimatedComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ function createAnimatedComponent<Props: {+[string]: mixed, ...}, Instance>(
this._propsAnimated && this._propsAnimated.__detach();
this._detachNativeEvents();
this._markUpdateComplete();
this._component = null;
this._prevComponent = null;
}
}

Expand Down

0 comments on commit 468bc62

Please sign in to comment.