Bug 833609 - Part 1: add a manual call to shrink memory usage to Sqlite.jsm. r=mak

This commit is contained in:
Gregory Szorc 2013-01-24 11:10:19 -08:00
parent 6c1628be1c
commit 640049a53f
2 changed files with 18 additions and 0 deletions

View File

@ -586,6 +586,15 @@ OpenedConnection.prototype = Object.freeze({
);
},
/**
* Free up as much memory from the underlying database connection as possible.
*
* @return Promise<>
*/
shrinkMemory: function () {
return this.execute("PRAGMA shrink_memory");
},
_executeStatement: function (sql, statement, params, onRow) {
if (statement.state != statement.MOZ_STORAGE_STATEMENT_READY) {
throw new Error("Statement is not ready for execution.");

View File

@ -323,3 +323,12 @@ add_task(function test_detect_multiple_transactions() {
yield c.close();
});
add_task(function test_shrink_memory() {
let c = yield getDummyDatabase("shrink_memory");
// It's just a simple sanity test. We have no way of measuring whether this
// actually does anything.
yield c.shrinkMemory();
yield c.close();
});