diff --git a/services/healthreport/healthreporter.jsm b/services/healthreport/healthreporter.jsm index 2104f2e0ad7a..482d08f4e487 100644 --- a/services/healthreport/healthreporter.jsm +++ b/services/healthreport/healthreporter.jsm @@ -307,6 +307,9 @@ HealthReporter.prototype = Object.freeze({ this._log.info("HealthReporter started."); this._initialized = true; Services.obs.addObserver(this, "idle-daily", false); + + // Clean up caches and reduce memory usage. + this._storage.compact(); this._initializedDeferred.resolve(this); }, @@ -695,6 +698,7 @@ HealthReporter.prototype = Object.freeze({ o.errors = errors; } + this._storage.compact(); throw new Task.Result(JSON.stringify(o)); }, diff --git a/services/metrics/storage.jsm b/services/metrics/storage.jsm index 1f590b229966..7dd432fa4a44 100644 --- a/services/metrics/storage.jsm +++ b/services/metrics/storage.jsm @@ -1204,6 +1204,21 @@ MetricsStorageSqliteBackend.prototype = Object.freeze({ }); }, + /** + * Reduce memory usage as much as possible. + * + * This returns a promise that will be resolved on completion. + * + * @return Promise<> + */ + compact: function () { + let self = this; + return this.enqueueOperation(function doCompact() { + self._connection.discardCachedStatements(); + return self._connection.shrinkMemory(); + }); + }, + /** * Ensure a field ID matches a specified type. *