Cleaning up fonts when viewer is idle for some time

This commit is contained in:
Yury Delendik 2013-11-14 13:43:38 -08:00
parent 945e370d4f
commit e712c4136a
9 changed files with 93 additions and 9 deletions

View file

@ -270,6 +270,9 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
dataLoaded: function PDFDocumentProxy_dataLoaded() {
return this.transport.dataLoaded();
},
cleanup: function PDFDocumentProxy_cleanup() {
this.transport.startCleanup();
},
destroy: function PDFDocumentProxy_destroy() {
this.transport.destroy();
}
@ -892,6 +895,21 @@ var WorkerTransport = (function WorkerTransportClosure() {
}
);
return promise;
},
startCleanup: function WorkerTransport_startCleanup() {
this.messageHandler.send('Cleanup', null,
function endCleanup() {
for (var i = 0, ii = this.pageCache.length; i < ii; i++) {
var page = this.pageCache[i];
if (page) {
page.destroy();
}
}
this.commonObjs.clear();
FontLoader.clear();
}.bind(this)
);
}
};
return WorkerTransport;