[Pkg-javascript-commits] [pdf.js] 102/207: Zero the height and width of the Cached canvases before deleting.

David Prévot taffit at moszumanska.debian.org
Mon Jul 28 15:36:36 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit 7ef7f95374e5ef327d2776ec149996ad97fecba9
Author: Nicholas Nethercote <nnethercote at mozilla.com>
Date:   Mon Jun 16 22:58:11 2014 -0700

    Zero the height and width of the Cached canvases before deleting.
    
    This reduces peak RSS by about 300 MiB on my Mac when scrolling slowly through
    the first 30 pages of a scanned black and white document.
---
 src/display/canvas.js | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/display/canvas.js b/src/display/canvas.js
index 5bd4fc9..fcedbae 100644
--- a/src/display/canvas.js
+++ b/src/display/canvas.js
@@ -179,7 +179,14 @@ var CachedCanvases = (function CachedCanvasesClosure() {
       return canvasEntry;
     },
     clear: function () {
-      cache = {};
+      for (var id in cache) {
+        var canvasEntry = cache[id];
+        // Zeroing the width and height causes Firefox to release graphics
+        // resources immediately, which can greatly reduce memory consumption.
+        canvasEntry.canvas.width = 0;
+        canvasEntry.canvas.height = 0;
+        delete cache[id];
+      }
     }
   };
 })();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list