Memory leaks

Discussion in 'Mac Programming' started by shilpa, Jul 9, 2008.

  1. shilpa macrumors member

    Joined:
    May 29, 2008
    #1
    Hi all,
    in my app

    NSAutoreleasePool *pool = [[NSAutoReleasePool alloc]init];
    cell.image = [UIImage initWithData:[NSData initWithContentsOfUrl:[NSURL URLWithString:mad:"http://images/image.jpg"]]];
    [pool release];

    when i see leaks in instruments and after tracing stack it will come and stop to this line:
    cell.image = [UIImage initWithData:[NSData initWithContentsOfUrl:[NSURL URLWithString:mad:"http://images/image.jpg"]]];

    NSAutoreleasePool *pool = [[NSAutoReleasePool alloc]init];
    i didnt had this line in my code earlier ,after geeting the leaks i added this line
    but still leaks are there in my app.

    Not only here i am parsing xml files in my app,where ever i use NSURL there are leaks in my code.

    NSXMLParser *parser = [[NSXMLParser alloc] initWithURL:[NSURL initWithString:URL]];
     
  2. Enuratique macrumors 6502

    Joined:
    Apr 28, 2008
    #2
    Looks like you and sujithkrishnan are having the same problem.

    Unfortunately no one has come to his rescue either. Could it be the URL not being freed? Perhaps there is a bug with NSData or UIImage? Sorry, without seeing more of your code, I can't tell what else could be going on.
     
  3. Mac Player macrumors regular

    Joined:
    Jan 19, 2006
    #3
    initWith methods are instance methods not class methods and the don't return auto released objects you must release them manually.
     
  4. pjrobertson macrumors 6502a

    Joined:
    Nov 14, 2007
    #4
    Not sure if I can help...I think I've just read about this in Stephen Kochan's book -

    (Taken from "Programmin in Objective - C", please remove if copyright infringement :eek:)

    So maybe you need something like:
    [[pool object] release]
     

Share This Page