Memory management when using sqlite database in iphone

前端 未结 6 1215
我在风中等你
我在风中等你 2021-02-03 16:18

My application makes use of a SQLite database to store the user\'s inputs. The number of records in the input would go to around 100 records and I have a lot of SQL operations g

6条回答
  •  深忆病人
    2021-02-03 16:37

    You really want to limit the cache size of sqlite in iphone applications. When you launch your application and initialize your database run a command like:

    const char *pragmaSql = "PRAGMA cache_size = 50";
    if (sqlite3_exec(database, pragmaSql, NULL, NULL, NULL) != SQLITE_OK) {
        NSAssert1(0, @"Error: failed to execute pragma statement with message '%s'.", sqlite3_errmsg(database));
    }
    

    this will prevent sqlite from caching your queries and slowly consuming all of your memory.

提交回复
热议问题