views:

259

answers:

1

Hi guys, I have a very strange memory leak problem, it seems that sqlite3_step is doing some nasty stuff :|

I spent almost 4 hours trying to fix this but no luck till now :(

Here it is the code:

[dbList removeAllObjects];

sqlite3_stmt *statement = nil;
const char *sql = "SELECT * FROM dbs ORDER by rowOrder;";
if (sqlite3_prepare_v2(dbHandler, sql, -1, &statement, NULL) == SQLITE_OK) 
{  
 while (sqlite3_step(statement) == SQLITE_ROW) 
 {

  DatabaseEntry *entry = [[DatabaseEntry alloc] init];

  entry.databaseID = sqlite3_column_int(statement, 0);
  entry.databaseTitle = [NSString stringWithFormat:@"%s", (char *)sqlite3_column_text(statement, 1)];
  entry.databaseProtected = sqlite3_column_int(statement, 3);
  entry.databaseFileName = [NSString stringWithFormat:@"%s", (char *)sqlite3_column_text(statement, 2)];
  entry.databaseOrder = sqlite3_column_double(statement, 4);

  [dbList addObject:entry];
  [entry release];
 }

}
sqlite3_finalize(statement);

The problem seems to be with my query, if I remove the "ORDER by rowOrder" part, everything seems to be just fine, also I'm using sqlcipher, and I'm wondering if that might cause this leak ?!

Thanks a lot for your attention !!!

+2  A: 

Update: Hey Andy, I was wrong. I started looking into this more closely after running through some scenarios in Leaks. It looks like a bad merge from the upstream SQLite source missed two pager cleanup calls. The issue caused page cache to remain allocated after the pager was closed. It probably wouldn't affect most programs, but I would still definitely recommend pulling down the latest source code that fixes the issue from GitHub at http://github.com/sjlombardo/sqlcipher

Stephen Lombardo
hmm, thats great to know, thank you !
Andy
Thanks, I will grab the new source code !Thanks a lot for looking into it :)
Andy