-1

When I take a page (page = doc.getPage), render it and then clean it (page.cleanup()), the page cache remains in the document object (doc), which accumulates and quickly clogs memory.

Tell me, please, is there any way to clear this cache or turn it off, other than just closing the document and opening it again (but it's slow)? PDF version.js v3.11.174

doc._transport.#pageCache and doc._transport.#pagePromises are private and methods for their I did not find any cleaning (doc.cleanup() and doc._transport.startCleanup() does not help, but doc.destroy() clears the entire document object and it is not an option to continue working with it).

New contributor
Slava is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
7
  • What does "clogs memory" mean? Even modern phones have gigabytes of memory, how much does that cache take up? Commented yesterday
  • @Mike'Pomax'Kamermans depends on the content of the page. 200 pages can easily take up 3GB of RAM if i don't clear the cache. But I need to process documents for 1000+ pages.
    – Slava
    Commented yesterday
  • If I abandon multiprocessing, consumption will drop, but it will still be too high
    – Slava
    Commented yesterday
  • PDF EITHER read 100% of GB or trickle from dedicated trickling (PDF.js Web Enhanced Ranges) SERVER drop your page count to no more than 100 MB or 1000 pages and even then it is too big for many devices to handle due to needing decompression at run time.
    – K J
    Commented yesterday
  • @KJ I open the pdf via the url, it doesn't seem to load everything at once, because memory consumption increases as pages are rendered, and if you periodically reset the cache by restarting the document (doc.destroy() and open it again), then consumption is greatly reduced, but it is slow. The document itself weighs much less. Pages with a complex vector structure consume more memory, while regular scans consume less. The file is downloaded from the user's computer (frontend)
    – Slava
    Commented yesterday

0

Browse other questions tagged or ask your own question.