MLeaksFinder icon indicating copy to clipboard operation
MLeaksFinder copied to clipboard

navigationController内存泄漏

Open chenhuchang opened this issue 7 years ago • 4 comments

当UINavigationController 有两层控制前的时候,调用[self.navigationController popViewControllerAnimated:YES]; 没有出现问题,调用[self.navigationController popToRootViewControllerAnimated:YES]; 会出现内存泄漏的情况,什么原因你呢

chenhuchang avatar Jan 08 '18 02:01 chenhuchang

先在报泄漏的类的 dealloc 里加断点,确认一下是不是真的没释放

Zepo avatar Jan 08 '18 02:01 Zepo

我的也是 [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];

TuDoudong avatar Jan 18 '18 03:01 TuDoudong

我看了下 1.0.0 好像 在 popViewControllerAnimated 没调用 [viewController willDealloc]; 没有触发检测

weijingyunIOS avatar Apr 18 '19 11:04 weijingyunIOS

看了下代码应该是代码有分类 实现了 + (void)load; 导致的

weijingyunIOS avatar Apr 18 '19 12:04 weijingyunIOS