Tried to add a destroy function to free memeory, but doesn't seem to help
This commit is contained in:
parent
20d8a13c9e
commit
921f8bd669
@ -50,6 +50,11 @@ function load() {
|
||||
window.onload = load;
|
||||
|
||||
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;
|
||||
}
|
||||
if (currentTaskIdx == manifest.length) {
|
||||
return done();
|
||||
}
|
||||
|
20
worker.js
20
worker.js
@ -182,7 +182,7 @@ var WorkerPDFDoc = (function() {
|
||||
var useWorker = true;
|
||||
|
||||
if (useWorker) {
|
||||
var worker = new Worker("../worker/boot_processor.js");
|
||||
var worker = this.worker = new Worker("../worker/boot_processor.js");
|
||||
} else {
|
||||
// If we don't use a worker, just post/sendMessage to the main thread.
|
||||
var worker = {
|
||||
@ -262,6 +262,24 @@ var WorkerPDFDoc = (function() {
|
||||
|
||||
var page = this.pdf.getPage(n);
|
||||
return this.pageCache[n] = new WorkerPage(this, page);
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
console.log("destroy worker");
|
||||
if (this.worker) {
|
||||
this.worker.terminate();
|
||||
}
|
||||
if (this.fontWorker) {
|
||||
this.fontWorker.terminate();
|
||||
}
|
||||
|
||||
for (var n in this.pageCache) {
|
||||
delete this.pageCache[n];
|
||||
}
|
||||
delete this.data;
|
||||
delete this.stream;
|
||||
delete this.pdf;
|
||||
delete this.catalog;
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user