1

Each time I push a new viewcontroller, it adds about 3MB. TestVC is a brand new VC with one method for pushing a new version of the VC.

 UIViewController *vc = [[TestVC alloc] initWithNibName:nibName bundle:nil]; 
    [self.navigationController pushViewController:vc animated:YES];
    [vc release];

When I popviewController, it doesn't release any memory (watching activity monitor).

[self.navigationController popViewControllerAnimated: YES];

So, as I add navigate through the app (about 60 different pages), memory keeps building up. Does initWithNibName need something special. When I pop, do I need to release the nib somehow?

occulus
  • 16,959
  • 6
  • 53
  • 76
smcdrc
  • 1,671
  • 2
  • 21
  • 29
  • There's nothing wrong with what you're doing there. Are you sure the problem is not attributed to something else? – David Mar 14 '11 at 16:52
  • What does `TestVC` look like? Do you release all your properties? No other memory leaks in there? As David says, there's nothing wrong with the way you're adding/removing view controllers. – Stephen Darlington Mar 14 '11 at 16:56
  • TestVC is an empty VC, except for the one IBAction to call the pushViewController code. The XIB file is has one button in it and a background image. – smcdrc Mar 14 '11 at 21:54

1 Answers1

2

The most likely problem is a failure to release something in -[TestVC dealloc]. I would evaluate that method by inspection first. If you can't find the problem, use the Leaks instrument in Instruments to find what particular thing is being over-retained. If Leaks doesn't find it, then use the heapshot tool in Instruments to see what's being allocated. With something so large, it should be easy to find. There's a quick overview of using Heapshot on Use Your Loaf.

Rob Napier
  • 286,113
  • 34
  • 456
  • 610
  • 1
    Using heapshots would be the first thing I'd do when diagnosing this. See also Bill Bumgarner's writeup on this here: http://www.friday.com/bbum/2010/10/17/when-is-a-leak-not-a-leak-using-heapshot-analysis-to-find-undesirable-memory-growth/ – Brad Larson Mar 14 '11 at 18:49