mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 22:58:07 +02:00
Merge pull request #804 from brendandahl/fixmemleak
Fix two memory leaks in testing framework.
This commit is contained in:
commit
25a8dbd04c
1 changed files with 13 additions and 7 deletions
|
@ -56,23 +56,29 @@ function load() {
|
|||
}
|
||||
|
||||
function cleanup() {
|
||||
var styleSheet = document.styleSheets[0];
|
||||
if (styleSheet) {
|
||||
// Clear out all the stylesheets since a new one is created for each font.
|
||||
while (document.styleSheets.length > 0) {
|
||||
var styleSheet = document.styleSheets[0];
|
||||
while (styleSheet.cssRules.length > 0)
|
||||
styleSheet.deleteRule(0);
|
||||
var ownerNode = styleSheet.ownerNode;
|
||||
ownerNode.parentNode.removeChild(ownerNode);
|
||||
}
|
||||
var guard = document.getElementById('content-end');
|
||||
var body = document.body;
|
||||
while (body.lastChild !== guard)
|
||||
body.removeChild(body.lastChild);
|
||||
|
||||
// Wipe out the link to the pdfdoc so it can be GC'ed.
|
||||
for (var i = 0; i < manifest.length; i++) {
|
||||
if (manifest[i].pdfDoc) {
|
||||
manifest[i].pdfDoc.destroy();
|
||||
delete manifest[i].pdfDoc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function nextTask() {
|
||||
// If there is a pdfDoc on the last task executed, destroy it to free memory.
|
||||
if (task && task.pdfDoc) {
|
||||
task.pdfDoc.destroy();
|
||||
delete task.pdfDoc;
|
||||
}
|
||||
cleanup();
|
||||
|
||||
if (currentTaskIdx == manifest.length) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue