From 625af8d2adac62fbc5223e5e8fee97406bdd442c Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 2 Jun 2019 22:18:21 +0200 Subject: [PATCH] [api-minor] Attempt to reduce memory usage during printing, by always running `cleanup` once rendering has finished Given that `cleanupAfterRender` is already set for large images, when handling 'obj' messages, this patch *should* thus be safe in general (since otherwise there ought be existing bugs related to cleanup and printing). --- src/display/api.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/display/api.js b/src/display/api.js index c6fbd182f..197e4c142 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -1004,7 +1004,7 @@ class PDFPageProxy { const stats = this._stats; stats.time('Overall'); - // If there was a pending destroy cancel it so no cleanup happens during + // If there was a pending destroy, cancel it so no cleanup happens during // this call to render. this.pendingCleanup = false; @@ -1044,7 +1044,9 @@ class PDFPageProxy { intentState.renderTasks.splice(i, 1); } - if (this.cleanupAfterRender) { + // Attempt to reduce memory usage during *printing*, by always running + // cleanup once rendering has finished (regardless of cleanupAfterRender). + if (this.cleanupAfterRender || renderingIntent === 'print') { this.pendingCleanup = true; } this._tryCleanup();