objective c - Help with a memory leak -


i made class uses nsurlconnection , kvc make objects plists on server. instruments says have bunch of memory leaks coming function handles data returned server:

- (void)connectiondidfinishloading:(nsurlconnection *)connection{     hasoutstandingcall = no;     nserror* serror;      nsdictionary* tmpdict = [nspropertylistserialization propertylistwithdata:receiveddata          options:nspropertylistimmutable         format:null error:&serror];     self.lastresponse = [serverresponse new];     //nslog(@"server responded: %@",tmpdict);     [lastresponse setvaluesforkeyswithdictionary:tmpdict];     if(tmpdict.count == 0){         lastresponse.success = no;         lastresponse.errorid = -1;         lastresponse.errormessage = @"couldn't understand server response";         [[nsnotificationcenter defaultcenter] postnotificationname:@"serverdidrespond" object:self];         [[nsnotificationcenter defaultcenter] postnotificationname:@"requestdidfail" object:self];         nslog(@"failed deserialize response");         nsstring* servermessage = [[nsstring alloc] initwithdata:receiveddata encoding:nsutf8stringencoding];         nslog(@"server said: %@",servermessage);          [servermessage release];         [receiveddata release];         return;     }      [[nsnotificationcenter defaultcenter] postnotificationname:@"serverdidrespond" object:self];      if(lastresponse.success){         if(lastresponse.resultquery)             nslog(@"%@ response: query %d rows",lastfname, lastresponse.resultquery.count);         else if(lastresponse.resultobject)             nslog(@"%@ response: object",lastfname);         [[nsnotificationcenter defaultcenter] postnotificationname:@"requestdidsucceed" object:self];     }else{         nslog(@"%@ response: error id: %d, message: %@",lastfname, lastresponse.errorid, lastresponse.errormessage);         [[nsnotificationcenter defaultcenter] postnotificationname:@"requestdidfail" object:self];     }      [receiveddata release]; } 

instruments says leaking server response, , bunch of other things pass through function. "responsable frame" thing refer whatever created leaked object no matter what? should looking how stuff gets leaked down road or have problem here in function? understand, tempdict, serror autoreleased when come serialization. i'm sending supposedly leaked serverresponse synthesized setter gets released in dealloc method, don't see problem is. got insight?

self.lastresponse = [serverresponse new]; 

that double retain, assuming lastresponse @property declared retain (or setter retains).

when instruments identifies leak, shows item allocated, may not cause of leak. leak unbalanced retain, retain on same line of allocation (as in case, apparently).


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -