Why instruments showing leak in "ODD" lines?

Discussion in 'Mac Programming' started by sujithkrishnan, Jul 8, 2008.

  1. sujithkrishnan macrumors 6502

    May 9, 2008
    Hi all.

    In my i Phone app, tehere are soem mem leaks the instuments detected.
    However its showing soem "ODD" lines when i trace the line from INSRUMENTS.

    Sometimes its showing the lines like

    @finally    // finallly block
    } // closing brace
    But i conccluded that the error is with the line above the specified line (which make sense)...

    Also i found that the leak is for the line where i assign the image for the cell of my UITableView.
    cell.image = [UIImage imageWithData:[NSData dataFromURL:[I]myImageURL[/I]]];
    The INSTRUMENTS showing leak for class NSURLResponse in this line.

    Also there is a leak for..
    recievedNSMutableData = [NSConnection sendSynchronousRequest:[I]request[/I] response:[I]&myNSMutableresponse[/I] error:[I]&connError[/I]];

    Plz help...
  2. ElectricSheep macrumors 6502


    Feb 18, 2004
    Wilmington, DE
    If you want to rule out autoreleased object weirdness, try explicitly allocating and releasing instead.

    So, instead of [NSData dataFromURL:myImageURL]; use NSData *foo = [[NSData alloc] initWithContentsOfURL:myImageURL];

    Instead of cell.image = [UIImage imageWithData:foo]; use UIImage *bar = [[UIImage alloc] initWithData:foo];.

    Then, you can pass bar to cell.image, and then explicitly release both it and foo. This is assuming that you have use the retain attribute when declaring the image property.

Share This Page