开发者

strange iphone sdk sqlite memory leak

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 !!!


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜