Why is this code producing an memory leak?
instruments, iphone, memory-leaks, memory-management
Solution
if MyVc.tabBarItem is already set, whatever it's pointing at may not be deallocated properly, causing a leak.
Problem
The Leaks Instrument in Xcode shows me an memory leak here. I have commented the affected line which Leaks is complaining about. But I see no error in my 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 released at the end, and the alloc IS balanced. So what's wrong? I don't get it.