事件,在instruments检查内存泄漏时发现其中一个viewcontroller在navigation做pop操作后未做dealloc,导致内存泄漏
push操作代码如下:
ViewController_leaveAMessage *leaveMessage = [[ViewController_leaveAMessage alloc]initWithNibName:@"ViewController_leaveAMessage" bundle:nil];
leaveMessage.toId = self.friendRS.userId;
[self.navigationController pushViewController:leaveMessage animated:YES];
[leaveMessage release];
pop操作后viewcontroller记述理应为0,从而调用dealloc。但是这断点后发现pop后未调用dealloc,说明该viewcontroller在其他地方还有引用。可是冲上面代码看出,正常情来说不该出该问题。后在push操作前后加log查看retainCount,发现该viewcontroller在push后retainCount增加了6,push其他viewcontroller其retainCount仅增加5.
其后逐条删除该viewcontroller中得viewdidload方法中得代码发现,其中因在viewdidload中执行
timer = [NSTimer scheduledTimerWithTimeInterval:0.3 target:selfselector:@selector(showLblTimeRecorderOrPlayer) userInfo:nil repeats:YES];