Skip to content

SQLiteOutOfMemoryException out of memory (code 7), no clear indication as to why #69

@frapontillo

Description

@frapontillo

Since we updated our library from android-database-sqlcipher to sqlcipher-android we've been getting multiple instances of these crashes:

Fatal Exception: android.database.sqlite.SQLiteOutOfMemoryException
out of memory (code 7): , while compiling: SELECT COUNT(*) FROM sqlite_schema;
net.zetetic.database.sqlcipher.SQLiteConnection.nativePrepareStatement (SQLiteConnection.java)
net.zetetic.database.sqlcipher.SQLiteConnection.acquirePreparedStatement (SQLiteConnection.java:973)
net.zetetic.database.sqlcipher.SQLiteConnection.executeForLong (SQLiteConnection.java:628)
net.zetetic.database.sqlcipher.SQLiteConnection.open (SQLiteConnection.java:240)
net.zetetic.database.sqlcipher.SQLiteConnection.open (SQLiteConnection.java:202)
net.zetetic.database.sqlcipher.SQLiteConnectionPool.openConnectionLocked (SQLiteConnectionPool.java:474)
net.zetetic.database.sqlcipher.SQLiteConnectionPool.open (SQLiteConnectionPool.java:188)
net.zetetic.database.sqlcipher.SQLiteConnectionPool.open (SQLiteConnectionPool.java:180)
net.zetetic.database.sqlcipher.SQLiteDatabase.openInner (SQLiteDatabase.java:1028)
net.zetetic.database.sqlcipher.SQLiteDatabase.open (SQLiteDatabase.java)
net.zetetic.database.sqlcipher.SQLiteDatabase.openDatabase (SQLiteDatabase.java:840)
net.zetetic.database.sqlcipher.SQLiteOpenHelper.getDatabaseLocked (SQLiteOpenHelper.java:359)
net.zetetic.database.sqlcipher.SQLiteOpenHelper.getWritableDatabase (SQLiteOpenHelper.java:278)
net.zetetic.database.sqlcipher.SupportHelper.getWritableDatabase (SupportHelper.java:60)
androidx.room.driver.SupportSQLiteDriver.open (SupportSQLiteDriver.android.kt:26)
androidx.room.driver.SupportSQLiteConnectionPool.getSupportConnection (SupportSQLiteConnectionPool.android.kt:35)
androidx.room.driver.SupportSQLiteConnectionPool.useConnection (SupportSQLiteConnectionPool.android.kt)
androidx.room.RoomConnectionManager.useConnection (RoomConnectionManager.android.kt:126)
androidx.room.RoomDatabase.useConnection$room_runtime_release (RoomDatabase.android.kt:593)
androidx.room.util.DBUtil__DBUtil_androidKt$performBlocking$1.invokeSuspend (DBUtil.android.kt:247)
androidx.room.util.DBUtil__DBUtil_androidKt$performBlocking$1.invoke (DBUtil.android.kt:2)
androidx.room.util.DBUtil__DBUtil_androidKt$performBlocking$1.invoke (DBUtil.android.kt:1)

This is just an example, we get the same android.database.sqlite.SQLiteOutOfMemoryException when SqlCipher calls getReadableDatabase, on multiple databases and on both Room and Content Provider.

This happens across all kinds of devices and OS versions, so it is not a limited subset of our user base.

Devices OS
Image Image

We have 2 databases, one accessed via Room, one via Content Providers.

At app startup, I see:

Database keying operation returned:0
Database keying operation returned:0
Database keying operation returned:0
Database keying operation returned:0
Database keying operation returned:0

Does this mean at least one of the 2 databases gets opened multiple times? I am providing access to these databases via singletons, so this shouldn't be happening, unless there is a race condition somewhere.

Is there any way to understand the actual reason behind this error?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions