开发者

Extra retain counts after initWithNibName

开发者 https://www.devze.com 2023-01-01 06:44 出处:网络
I have extra retain counts after calling initWithNib. What could cause this? (There are no referenc开发者_JAVA百科ing outlets in the nib)

I have extra retain counts after calling initWithNib. What could cause this? (There are no referenc开发者_JAVA百科ing outlets in the nib)

StepViewController *stepViewController = [[StepViewController alloc] initWithNibName:@"StepViewController" bundle:nil];
[self.navigationController pushViewController:stepViewController animated:YES];
[stepViewController release];
NSLog(@"nextStep stepViewController retain count %i", [stepViewController retainCount]);

the above results in a retain count of 3...

Thanks for any advice on how to troubleshoot


What are you troubleshooting? There is nothing wrong here. -retainCount is not your business and tells you almost nothing about the system. Every object that is autoreleased will have an apparent retainCount higher than you think it will be. If internal objects are interested in this object, they will have their own retains that you may or may not expect.

Your business is to balance your own retains and releases. The rest of the system is responsible for balancing theirs. You should not second-guess it, and if you do, -retainCount is unlikely to help you much anyway. It is almost always more misleading than helpful.

Is there actually a leak going on that you're concerned about?


You would have to look into the source code or API documentation to find out. But it would seem logical that the nvaigation controller has one and the view loaded out of the xib has one, so that's probably another being done by something in the naviation controller would be my guess.

0

精彩评论

暂无评论...
验证码 换一张
取 消