English 中文(简体)
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

问题回答

暂无回答




相关问题
sqlite3 is chopping/cutting/truncating my text columns

I have values being cut off and would like to display the full values. Sqlite3 -column -header locations.dbs " select n.namelist, f.state, t.state from names n left join locations l on l.id = n.id ...

Entity Framework with File-Based Database

I am in the process of developing a desktop application that needs a database. The application is currently targeted to SQL Express 2005 and works wonderfully. However, I m not crazy about having ...

Improve INSERT-per-second performance of SQLite

Optimizing SQLite is tricky. Bulk-insert performance of a C application can vary from 85 inserts per second to over 96,000 inserts per second! Background: We are using SQLite as part of a desktop ...

Metadata for columns in SQLite v2.8 (PHP5)

How can I get metadata / constraints (primary key and "null allowed" in particular) for each column in a SQLite v2.8 table using PHP5 (like mysql_fetch_field for MySql)? sqlite_fetch_column_types (OO:...

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签