Resolved severe memory leak (mozPrintCallback)

Do NOT save the temporary <canvas> element as `this.canvas`.
`PDFViewer.pages[i].canvas` appears to be used to generate the thumbnail
icons. Well, that's no justification for preventing GC of those
temporary <canvas> elements used during mozPrintCallback.

With a document consisting of 79 pages, this resulted in a 600-700MB
leaked memory.
This commit is contained in:
Rob Wu 2013-10-02 00:03:32 +02:00
parent 1731c0fb42
commit 194a734e5d

View File

@ -514,7 +514,7 @@ var PageView = function pageView(container, id, scale,
// Use the same hack we use for high dpi displays for printing to get better
// output until bug 811002 is fixed in FF.
var PRINT_OUTPUT_SCALE = 2;
var canvas = this.canvas = document.createElement('canvas');
var canvas = document.createElement('canvas');
canvas.width = Math.floor(viewport.width) * PRINT_OUTPUT_SCALE;
canvas.height = Math.floor(viewport.height) * PRINT_OUTPUT_SCALE;
canvas.style.width = (PRINT_OUTPUT_SCALE * viewport.width) + 'pt';