views:

108

answers:

3

Are these kind of leaks normal? Are they false leaks or something I should be concerned with? The instruments tool doesn't give me any line of code from my app, seems Apple's frameworks are leaking?! alt text

Ok, the problems could only come from here:

  • (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {

    DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"ProjectDetailView" bundle:[NSBundle mainBundle]];

    Project *project = [projectsArray objectAtIndex:indexPath.row];

    [detailViewController setProject:project];

    [detailViewController setTitle:[project name]];

    [self.navigationController pushViewController:detailViewController animated:YES];

    [detailViewController release];

}

OR from the detail view's viewWillAppear event:

  • (void)viewWillAppear:(BOOL)animated {

    [super viewWillAppear:animated];

    [projectName setText:[project name]];

    [appDefStatement setText:[project appDefStatement]];

    [projectDesc setText:[project desc]];

    NSMutableArray *theSketches = [[NSMutableArray alloc] initWithArray:[project.sketches allObjects]];

    [self setSketchesArray:theSketches];

    [theSketches release];

    if([sketchesArray count] == 0) {

    [tView setHidden:YES];  
    

    } else {

    [tView setHidden:NO];
    

    }

}

+1  A: 

There are very few cases where the leaks come from Apple's source code, so I would say first things first:

  1. Anytime you use alloc you need to release whatever object you created at a later, safe time
  2. Make sure any objects that are synthesized in the .m file are released in dealloc call
  3. Read this helpful (albeit boring) article on memory management: http://developer.apple.com/iphone/library/documentation/cocoa/conceptual/memorymgmt/memorymgmt.html
  4. Walk through this great example on Leaks http://www.mobileorchard.com/find-iphone-memory-leaks-a-leaks-tool-tutorial/

P.S. Without posting your code, we can only speculate... you'd get better answers by posting the suspect code.

iWasRobbed
Thanks, I will look into those articles. Problem is what code to post? I'd have to post all the code (and it's long), since the Instruments don't point me to a line in my code, they only show me lines of code written by someone else (i.e. Apple).
Marian Busoi
I would start with code that you wrote dealing with your tables and text views.
iWasRobbed
I added some code.
Marian Busoi
A: 

Although is possible that somethings apple code has leaks, the fact that you see a leak there it doesn't mean that leaks is actually there. For instance, it could be that you alloc something from apple's framework and then you didn't release properly.

Hope this helps.

Greetings

Rafael
I realise that, just can't see where that happens. I double/triple checked and I seem to release everything that needs to be released...
Marian Busoi
A: 

I think these are false leaks. One of the leaks even shows up for a line of code taken from Apple's documentation (the line from cellForRowAtIndexPath that attempts to fetch a reusable cell). So my guess is the Leaks instrument is not perfect. I have checked my code a number of times and made sure I am releasing everything that has been alloced/copied/retained/mutableCopied etc etc.

Marian Busoi
I wouldn't dwell on it too long then since I've had the same thing happen. I've found leaks in `AVAudioPlayer` that are a result of Apple's code and I could do nothing about, so it's best to just move on. At least now you have more experience with leaks!
iWasRobbed