MLeaksFinder
MLeaksFinder copied to clipboard
navigationController内存泄漏
当UINavigationController 有两层控制前的时候,调用[self.navigationController popViewControllerAnimated:YES]; 没有出现问题,调用[self.navigationController popToRootViewControllerAnimated:YES]; 会出现内存泄漏的情况,什么原因你呢
先在报泄漏的类的 dealloc 里加断点,确认一下是不是真的没释放
我的也是 [self.navigationController popToRootViewControllerAnimated:YES] 发生泄漏 不过 [self.navigationController popToRootViewControllerAnimated:NO] 就不会发生泄漏 在dealloc 里面已经确认过,代码是在退出登录 切换rootviewcontroller 造成的 if (weakself.navigationController) { [weakself.navigationController popToRootViewControllerAnimated:YES]; }else{ [weakself dismissViewControllerAnimated:YES completion:nil]; } LoginNewController *loginNewVC = [[LoginNewController alloc] init]; AppDelegate *delegateB = (AppDelegate *)[UIApplication sharedApplication].delegate; delegateB.mainController = nil; delegateB.like_mainController = nil; delegateB.window.rootViewController = loginNewVC; [delegateB.window makeKeyAndVisible];
我看了下 1.0.0 好像 在 popViewControllerAnimated 没调用 [viewController willDealloc]; 没有触发检测
看了下代码应该是代码有分类 实现了 + (void)load; 导致的