Why instruments showing leak in "ODD" lines?

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

  1. sujithkrishnan macrumors 6502

    Joined:
    May 9, 2008
    Location:
    Bangalore
    #1
    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

    Code:
    @finally    // finallly block
    
    Code:
    } // 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.
    Code:
    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..
    Code:
    recievedNSMutableData = [NSConnection sendSynchronousRequest:[I]request[/I] response:[I]&myNSMutableresponse[/I] error:[I]&connError[/I]];
    
    [/CODE]

    Plz help...
     
  2. ElectricSheep macrumors 6502

    ElectricSheep

    Joined:
    Feb 18, 2004
    Location:
    Wilmington, DE
    #2
    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