facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.15k stars 24.21k forks source link

RCTView cause memory leak #38238

Closed OrrHsiao closed 1 year ago

OrrHsiao commented 1 year ago

Description

RCTView can not be released by quite ReactNativePage

React Native Version

0.71.4

Output of npx react-native info

System: OS: macOS 13.0.1 CPU: (8) arm64 Apple M1 Memory: 58.88 MB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 18.11.0 - /opt/homebrew/bin/node Yarn: 1.22.19 - /opt/homebrew/bin/yarn npm: 8.19.2 - /opt/homebrew/bin/npm Watchman: Not Found Managers: CocoaPods: 1.12.1 - /Users/orrhsiao/.rvm/gems/ruby-2.7.6/bin/pod SDKs: iOS SDK: Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1 Android SDK: Not Found IDEs: Android Studio: 2022.1 AI-221.6008.13.2211.9477386 Xcode: 14.2/14C18 - /usr/bin/xcodebuild Languages: Java: Not Found npmPackages: @react-native-community/cli: Not Found react: 18.2.0 => 18.2.0 react-native: 0.71.4 => 0.71.4 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

https://github.com/OrrHsiao/ReactNativeDemo You can use this example to reproduce the problem Repeat step

Open demo and run iOS programs. Click the "push" button to jump to the RN page. Click "jump hello word" to go to the Page1 component page. Click on the navigation bar return arrow "<" Close the RN page. Observe that XATestView does not execute the dealloc function.

Snack, code example, screenshot, or link to a repository

https://github.com/OrrHsiao/ReactNativeDemo

github-actions[bot] commented 1 year ago
:warning: Newer Version of React Native is Available!
:information_source: You are on a supported minor version, but it looks like there's a newer patch available - 0.71.12. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.
cortinico commented 1 year ago

Observe that XATestView does not execute the dealloc function.

What do you mean with "Observe" here? Can you be more specific?

OrrHsiao commented 1 year ago

Observe that XATestView does not execute the dealloc function.

What do you mean with "Observe" here? Can you be more specific?

I mean that XATestView‘s instance can't be released == XATestView instance function “-(void) dealloc” can‘t be called when i close the RN page

OrrHsiao commented 1 year ago

we have found the reason:https://github.com/software-mansion/react-native-screens/issues/1754