From 75a91389b29f7101746b8e9d6889b333ced7e917 Mon Sep 17 00:00:00 2001 From: Gregory Szorc Date: Thu, 24 Jan 2013 11:10:19 -0800 Subject: [PATCH] Bug 833609 - Part 1: add a manual call to shrink memory usage to Sqlite.jsm. r=mak --- toolkit/modules/Sqlite.jsm | 9 +++++++++ toolkit/modules/tests/xpcshell/test_sqlite.js | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/toolkit/modules/Sqlite.jsm b/toolkit/modules/Sqlite.jsm index ead715b1a1b3..ca9aa6c9a3c2 100644 --- a/toolkit/modules/Sqlite.jsm +++ b/toolkit/modules/Sqlite.jsm @@ -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."); diff --git a/toolkit/modules/tests/xpcshell/test_sqlite.js b/toolkit/modules/tests/xpcshell/test_sqlite.js index 1f4455332d31..3dc4a8cde1c7 100644 --- a/toolkit/modules/tests/xpcshell/test_sqlite.js +++ b/toolkit/modules/tests/xpcshell/test_sqlite.js @@ -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(); +});