Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MACloop

macrumors 6502
Original poster
May 18, 2009
393
0
Germany
Hello,
I use a combination of a tabBar and a navigationcontroller based on
this example. Testing my app in the Leaks-tool, it indicates a leak in my appDelegate after that where I have defined my 4 navigation controllers. I have marked the content red where the leak is supposed to be. My problem is that I do not know why my app is leaking here? Any ideas? What should I be seaching for? It leaks 128 Bytes if that may be some indication here...

Thanks in advance!
MACloop

Code:
...
[COLOR="DarkGreen"]//code like this is added 4 times[/COLOR]
TableViewController *tableViewController;
	tableViewController = [[TableViewController alloc] initWithNibName:@"tableViewController" bundle:nil];
	localNavigationController = [[UINavigationController alloc] initWithRootViewController:tableViewController];
	localNavigationController.navigationBar.tintColor = [UIColor lightGrayColor];
	[localNavigationController.tabBarItem initWithTitle:@"Table" image:[UIImage imageNamed:@"some_pic.png"] tag:4];
	[localControllersArray addObject:localNavigationController];
	[COLOR="Red"][localNavigationController release];
	[tableViewController release];
...

[COLOR="DarkGreen"]//the tabBarController is retained in the .h file and is released in the dealloc method[/COLOR]
	tabBarController.viewControllers = localControllersArray;
	[COLOR="Red"][localControllersArray release];[/COLOR]
	[window addSubview:tabBarController.view];
 
You have to show us the code where localControllersArray is assigned its value.

No one can tell whether a release is appropriate without seeing how the object was obtained.
 
You have to show us the code where localControllersArray is assigned its value.

No one can tell whether a release is appropriate without seeing how the object was obtained.

ok, this is how it looks like:
Code:
NSMutableArray *localControllersArray = [[NSMutableArray alloc] initWithCapacity:4];

alloc is doen once and retain is done once...
MACloop
 
you call alloc then retain it? Sounds like it probably has a retain count that's too high to actually be released. What happens if you don't retain it?

Also is that a deep or a shallow copy happening there? You might end up with a bad access or something once the localControllersArray is released properly.
 
Now post the code where the retain is done once.

ups...sorry :eek: it should of course have been:
alloc once and RELEASE once...my mistake. I do not retain it I alloc and when it is added to the navigation I release it... As I can see it: alloc is +1 release is -1 making the sum 0.... hmmm?
MACloop
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.