diff options
author | Vasu Nori <vnori@google.com> | 2010-12-21 09:32:36 -0800 |
---|---|---|
committer | Vasu Nori <vnori@google.com> | 2010-12-21 09:32:36 -0800 |
commit | 34ad57f0e844cd97f59d4ab22087d60d58650ba4 (patch) | |
tree | c254d651eeb62d76fc7fe5ab852b237857bd7b09 /core/java/android/database | |
parent | 96abab264e4d96071dc169b4828e950c1ae59681 (diff) | |
download | frameworks_base-34ad57f0e844cd97f59d4ab22087d60d58650ba4.zip frameworks_base-34ad57f0e844cd97f59d4ab22087d60d58650ba4.tar.gz frameworks_base-34ad57f0e844cd97f59d4ab22087d60d58650ba4.tar.bz2 |
resubmitting Change-Id: I67b1d04a5c9fc18b0cd4da6184d0b814b64d89e9
Change-Id: I67b1d04a5c9fc18b0cd4da6184d0b814b64d89e9 was reverted
due to a bug. fixed the bug and resubmitting it here
Diffstat (limited to 'core/java/android/database')
-rw-r--r-- | core/java/android/database/CursorWindow.java | 12 | ||||
-rw-r--r-- | core/java/android/database/sqlite/SQLiteDatabase.java | 16 |
2 files changed, 26 insertions, 2 deletions
diff --git a/core/java/android/database/CursorWindow.java b/core/java/android/database/CursorWindow.java index a026eca..9a8f2d2 100644 --- a/core/java/android/database/CursorWindow.java +++ b/core/java/android/database/CursorWindow.java @@ -16,6 +16,7 @@ package android.database; +import android.content.res.Resources; import android.database.sqlite.SQLiteClosable; import android.os.IBinder; import android.os.Parcel; @@ -25,6 +26,13 @@ import android.os.Parcelable; * A buffer containing multiple cursor rows. */ public class CursorWindow extends SQLiteClosable implements Parcelable { + /** The cursor window size. resource xml file specifies the value in kB. + * convert it to bytes here by multiplying with 1024. + */ + private static final int sCursorWindowSize = + Resources.getSystem().getInteger( + com.android.internal.R.integer.config_cursorWindowSize) * 1024; + /** The pointer to the native window class */ @SuppressWarnings("unused") private int nWindow; @@ -38,7 +46,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable { */ public CursorWindow(boolean localWindow) { mStartPos = 0; - native_init(localWindow); + native_init(sCursorWindowSize, localWindow); } /** @@ -574,7 +582,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable { private native IBinder native_getBinder(); /** Does the native side initialization for an empty window */ - private native void native_init(boolean localOnly); + private native void native_init(int cursorWindowSize, boolean localOnly); /** Does the native side initialization with an existing binder from another process */ private native void native_init(IBinder nativeBinder); diff --git a/core/java/android/database/sqlite/SQLiteDatabase.java b/core/java/android/database/sqlite/SQLiteDatabase.java index 184988b..6f59dc9 100644 --- a/core/java/android/database/sqlite/SQLiteDatabase.java +++ b/core/java/android/database/sqlite/SQLiteDatabase.java @@ -18,6 +18,7 @@ package android.database.sqlite; import android.app.AppGlobals; import android.content.ContentValues; +import android.content.res.Resources; import android.database.Cursor; import android.database.DatabaseErrorHandler; import android.database.DatabaseUtils; @@ -1963,6 +1964,15 @@ public class SQLiteDatabase extends SQLiteClosable { // If the caller sets errorHandler = null, then use default errorhandler. mErrorHandler = (errorHandler == null) ? new DefaultDatabaseErrorHandler() : errorHandler; mConnectionNum = connectionNum; + /* sqlite soft heap limit http://www.sqlite.org/c3ref/soft_heap_limit64.html + * set it to 4 times the default cursor window size. + * TODO what is an appropriate value, considring the WAL feature which could burn + * a lot of memory with many connections to the database. needs testing to figure out + * optimal value for this. + */ + int limit = Resources.getSystem().getInteger( + com.android.internal.R.integer.config_cursorWindowSize) * 1024 * 4; + native_setSqliteSoftHeapLimit(limit); } /** @@ -2670,4 +2680,10 @@ public class SQLiteDatabase extends SQLiteClosable { * @param statementId statement to be finzlied by sqlite */ private final native void native_finalize(int statementId); + + /** + * set sqlite soft heap limit + * http://www.sqlite.org/c3ref/soft_heap_limit64.html + */ + private native void native_setSqliteSoftHeapLimit(int softHeapLimit); } |