The "out of memory" error is often a misleading error message caused by trying to use a database without having opened it first (or if you accidentally set the sqlite3
database pointer to NULL
). For example:
sqlite3 *db = NULL;
sqlite3_stmt *statement;
int rc;
// deliberately did not open database -- ERROR
// now try to use SQLite without opening database
if ((rc = sqlite3_prepare_v2(db, "select * from test", -1, &statement, NULL)) != SQLITE_OK)
NSLog(@"rc=%d errmsg=%s", rc, sqlite3_errmsg(db));
This will generate a return code (rc
) of 21
, SQLITE_MISUSE
. And the error message is a misleading "out of memory":
2014-05-11 17:36:22.035 MyApp[19942:60b] rc=21 errmsg=out of memory