mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
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.
This commit is contained in:
parent
2efbdfe8d4
commit
7ef7f95374
1 changed files with 8 additions and 1 deletions
|
@ -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];
|
||||
}
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue