Merge pull request #804 from brendandahl/fixmemleak
Fix two memory leaks in testing framework.
This commit is contained in:
commit
25a8dbd04c
@ -56,23 +56,29 @@ function load() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
var styleSheet = document.styleSheets[0];
|
// Clear out all the stylesheets since a new one is created for each font.
|
||||||
if (styleSheet) {
|
while (document.styleSheets.length > 0) {
|
||||||
|
var styleSheet = document.styleSheets[0];
|
||||||
while (styleSheet.cssRules.length > 0)
|
while (styleSheet.cssRules.length > 0)
|
||||||
styleSheet.deleteRule(0);
|
styleSheet.deleteRule(0);
|
||||||
|
var ownerNode = styleSheet.ownerNode;
|
||||||
|
ownerNode.parentNode.removeChild(ownerNode);
|
||||||
}
|
}
|
||||||
var guard = document.getElementById('content-end');
|
var guard = document.getElementById('content-end');
|
||||||
var body = document.body;
|
var body = document.body;
|
||||||
while (body.lastChild !== guard)
|
while (body.lastChild !== guard)
|
||||||
body.removeChild(body.lastChild);
|
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() {
|
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();
|
cleanup();
|
||||||
|
|
||||||
if (currentTaskIdx == manifest.length) {
|
if (currentTaskIdx == manifest.length) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user