Merge pull request #14968 from Snuffleupagus/api-release-data

A small memory-usage improvement for PDF documents opened from TypedArray-data
This commit is contained in:
Jonas Jenwald 2022-05-29 18:35:12 +02:00 committed by GitHub
commit 1ac33c960d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -513,6 +513,12 @@ async function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
}
);
// Release the TypedArray data, when it exists, since it's no longer needed
// on the main-thread *after* it's been sent to the worker-thread.
if (source.data) {
source.data = null;
}
if (worker.destroyed) {
throw new Error("Worker was destroyed");
}
@ -953,8 +959,8 @@ class PDFDocumentProxy {
}
/**
* @returns {Promise<TypedArray>} A promise that is resolved with a
* {TypedArray} that has the raw data from the PDF.
* @returns {Promise<Uint8Array>} A promise that is resolved with a
* {Uint8Array} that has the raw data from the PDF.
*/
getData() {
return this._transport.getData();