Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Memory consumption - Special Use case #5469
Comments
|
I think you forgot to call |
|
calling page.destroy just before
Doesn't help much. |
|
Is there something special about your 22MB pdf? Such as lots of hi-res images, huge pages, lots of fonts, etc. |
|
Just to note "cosa"/reader.readAsDataURL(file); consumes at least 30MB (base64 on main thread) + 30MB (base64 in the worker) + 22MB as Uint8Array(in the worker) at some point. Could you readAsArrayBuffer and init the getDocument with Uint8Array and not use data URL? |
|
That example was old; I'm using URL.createObjectURL(file) now, do you consider readAsArrayBuffer better than createObjectURL? http://jsfiddle.net/zkq19spu/4/ Using readAsArrayBuffer my ram usage (OS) goes 970 ->1387 (when running the demo) with a 802KB, 45 pages long PDF file, which is mostly text over a background. I know this is an edge case (iterating over the entire PDF file as fast as possible) |
|
Tried a 23M document and your jsfiddle, ff nightly did not consume more than 650MB (And I suspect 100MB of that just duplicate of the initial pdf data in base64 or binary form, some of that Firefox itself, rest of that font and other caches): Can you also specify your configuration: browser, os and their versions? |
|
Using URL.createObjectURL(file) is better if it works for you. Please provide URL to your PDF document |
|
Ok this is a 22MB, 112Page pdf (somewhat nsfw) that was given to me by a doctor. This is an 802KB, 47 page pdf (totally sfw) I'm looking to get this working on mobile, so '650MB' of ram is a pretty big deal. I don't know if there's an easy way to discard 'old' (as in not-currently-active) pages/canvases. |
|
I tried to destroy all previous pages on WorkerTransport_getPage, but it seems like they get marked as "pendingDestroy" but do not get destroyed shortly (should it be immediately?) Around line 2690
add
Every time this runs I get every slide logged: Also, I tried adding a 1 second delay between page renders, it helped a little bit (peak consumption went from 300MB to 250MB) |
|
Is this still an issue with the latest version? @DavidVentura |
|
No response, closing for now. |


I made the following example: http://jsfiddle.net/zkq19spu/2/
This represents my use case: Drawing a page of a PDF to a canvas, doing something to the canvas, then saving the image, drawing the next page to the canvas [..]
This seems to be an edge case, because the memory usage shoots to over 900MB with a 22MB pdf.
Could you help me to modify the source to:
*Disable the cache or shrink it to the minimum size
*Delete the canvas on render finish
With my use case I don't need to go back to the previous pages, and after the rendering is finished I don't need it anymore.