Skip to content

Commit

Permalink
Merge pull request #14968 from Snuffleupagus/api-release-data
Browse files Browse the repository at this point in the history
A small memory-usage improvement for PDF documents opened from TypedArray-data
  • Loading branch information
Snuffleupagus authored May 29, 2022
2 parents 3fdf2ba + 7e85285 commit 1ac33c9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/display/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 1ac33c9

Please sign in to comment.