Why does this code create a memory leak?

The Leakage tool in Xcode shows me a memory leak here. I commented on the affected line that Leak complains about. But I do not see errors in memory management ...

- (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];
}

I mean ... tbi and myVC IS are released at the end, and alloc is balanced. So what? I do not understand.

+5
source share
2 answers

if MyVc.tabBarItem is already installed, then what it indicates may not be released properly, causing a leak.

+3
source

It just shows that at least one of the following statements is true:

  • , ( ).
  • Apple .

.

+2

All Articles