Friday, December 20, 2013

Memory release problem solving.

- (NSMutableArray *) findContactInfoWithuseid: (NSString *) userid
{
NSMutableArray * list = [[[NSMutableArray alloc] init] autorelease];
/ / ResultSet * rs = [[DBHelper sharedInstance] database executeQuery:. @ "? SELECT * FROM PliceContact where userId =", userid];
ResultSet * rs = [[DBHelper sharedInstance] database executeQuery: @ "SELECT * FROM PliceContact where userId".];
while ([rs next]) {
ContactInfo * info = [[ContactInfo alloc] init];
info._userId = [rs stringForColumnIndex: 0];
info._department = [rs stringForColumnIndex: 1];
info._userName = [rs stringForColumnIndex: 2];
info._recordId = [rs stringForColumnIndex: 3];
[List addObject: info];
[Info release];
}
return list;
}

- (Void) getPoliceListData {
NSLog (@ "get the list");
NSMutableArray * resultArray = [[NSMutableArray alloc] init];
resultArray = [[TableMaintenance sharedInstance] findContactInfoWithuseid: @ "1"];
NSLog (@ "resultArray =% @", resultArray);

[ResultArray release] ;/ / side release will collapse, and why not?
}

Reply:
Hair up to look at the contents of the error
Reply:
Thank you, I already know the reason, because it points to an autorelease initialization indeed returnCount plus 1
But resultArray point to a autorelease, it is another piece from the new point to memory, and this block of memory is automatically released
Not because the previous memory plus one count of how much, thank you for concern.
Reply:
Content to be used have been released out.
Reply:
NSMutableArray * resultArray = [[NSMutableArray alloc] init];
resultArray = [[TableMaintenance sharedInstance] findContactInfoWithuseid: @ "1"]; ruthless problem
Reply:
LS ask what the problem? I did not find any issues, is a single case

No comments:

Post a Comment