From 468bc62da33d65fc3a64db834c5e57cdf5f1d993 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Wed, 24 Feb 2021 17:12:58 -0800 Subject: [PATCH] Animated JS: clear out component refs on unmount 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 --- Libraries/Animated/createAnimatedComponent.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Libraries/Animated/createAnimatedComponent.js b/Libraries/Animated/createAnimatedComponent.js index 988139fdd7fda3..fda18f0af80744 100644 --- a/Libraries/Animated/createAnimatedComponent.js +++ b/Libraries/Animated/createAnimatedComponent.js @@ -299,6 +299,8 @@ function createAnimatedComponent( this._propsAnimated && this._propsAnimated.__detach(); this._detachNativeEvents(); this._markUpdateComplete(); + this._component = null; + this._prevComponent = null; } }