Can anybody help me out why this piece of code is leaking and how can we handle it?
const char *sqlStatement = "SELECT * FROM VIOLATIONS_TBL";
sqlite3_stmt *compiledStatement;
if (sqlite3_prepare(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
while (sqlite3_step(compiledStatement) == SQLITE_ROW) {
NSString *recSTR=[[NSString alloc] initWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];
[self.pickerList addObject:recSTR];
[recSTR release];
recSTR=nil;
}
}
recSTR is leaking in this case and I have tried all the below mentioned solutions but none worked Thanx in advance
If your loop is running for a huge number of times then use autorelease pool
It might help you prevent memory leak
got the solution leak is here
handle this and we are done