mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-24 08:08:43 +00:00
Upgrade SQLCipher to respect a max window size.
Previously, SQLCipher's memory usage would grow indefinitely, up until it hit the end of the cursor. We've now switched to a release where the memory used by the cursor can be bounded.
This commit is contained in:
@@ -8,6 +8,9 @@ import android.os.SystemClock;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
import net.sqlcipher.CursorWindow;
|
||||
import net.sqlcipher.CursorWindowAllocation;
|
||||
import net.sqlcipher.CustomCursorWindowAllocation;
|
||||
import net.sqlcipher.database.SQLiteDatabase;
|
||||
import net.sqlcipher.database.SQLiteDatabaseHook;
|
||||
import net.sqlcipher.database.SQLiteOpenHelper;
|
||||
@@ -52,6 +55,14 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
|
||||
private static final int DATABASE_VERSION = 9;
|
||||
private static final String DATABASE_NAME = "signal.db";
|
||||
|
||||
private static final int MEMORY_INITIAL = 128 * 1024;
|
||||
private static final int MEMORY_GROW = 1024 * 1024;
|
||||
private static final int MEMORY_MAX = 4 * 1024 * 1024;
|
||||
private static final CursorWindowAllocation CURSOR_ALLOCATION = new CustomCursorWindowAllocation(MEMORY_INITIAL, MEMORY_GROW, MEMORY_MAX);
|
||||
static {
|
||||
CursorWindow.setCursorWindowAllocation(CURSOR_ALLOCATION);
|
||||
}
|
||||
|
||||
private final Context context;
|
||||
private final DatabaseSecret databaseSecret;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user