为什么这段代码会产生内存泄漏?

don*_*ile 5 iphone memory-leaks memory-management instruments

Xcode中的Leaks Instrument向我展示了内存泄漏.我评论了Leaks抱怨的受影响的线路.但我看到我的内存管理没有错误......

- (void)setupViewController {
    MyViewController *myVC = [[MyViewController alloc] init];

    UITabBarItem *tbi = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemDownloads tag:1];
    myVC.tabBarItem = tbi; // LEAK: 128 bytes

    self.myViewController = myVC;

    [myVC release];
    [tbi release];
}
Run Code Online (Sandbox Code Playgroud)

我的意思是... tbi和myVC IS在最后发布,并且alloc IS平衡.那有什么不对?我不明白.

pat*_*ros 3

如果 MyVc.tabBarItem 已设置,则它指向的任何内容都可能无法正确释放,从而导致泄漏。