Description
Is this a bug report?
Yes
Have you read the Contributing Guidelines?
Yes
Environment
react-native -v
: 0.47.0node -v
: v8.1.2npm -v
: 5.3.0yarn --version
: not use
Then, specify:
- Target Platform: iOS
- Development Operating System: macOS
- Build tools: Xcode
Steps to Reproduce
(Write your steps here:)
1.create new project
react-native init demo
2. create a new ViewController, and delete all the code in AppDelegate
3.add the RCTRootView to ViewController
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
NSURL *jsCodeLocation;
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"demo"
initialProperties:nil
launchOptions:nil];
rootView.frame = self.view.frame;
[self.view addSubview:rootView];
}
@end
4、run the project
Expected Behavior
When the ViewController has been popped from UINavigationController, the RCTRootView and RCTBridge has to call dealloc methos
Actual Behavior
ViewController and RCTRootView has called dealloc method, but RCTBridge hasn't call dealloc, become leak.
I use debug memory graph, it shows ViewControll and RCTRootView has been released, but when open ViewController again and again, the number of RCTBrigde will increase, the memory also increase
Reproducible Demo
Demo Link
I try to fix the issue, add [_bridge invalidate] to RCTRootView dealloc method. It works, RCTBridge calls dealloc methods when RCTRootView dealloc.
RCTRootView
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
[_contentView invalidate];
[_bridge invalidate];
}