-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory issue with creating a doc with a lot of images #861
Comments
rsshilli
added a commit
to rsshilli/pdfkit
that referenced
this issue
Aug 24, 2018
Closed
For those looking for a work-around for version 0.8.x, try this:
|
Probably fixed by #889 . The issue still can occur because png-js decodePixels calls zlib inflate async, but odds are much smaller. Please test and if still occurs reopen with a sample code |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm creating a document that has 750+ pages where each page has a different screenshot. The total doc size is 48 MB and it takes ~4 mins to create, which seems fine. What's not fine is that it take ~6 GB of memory to create this 48 MB file.
At first I thought I had the same problem as #728 but when I tried @blikblum's branch which includes both the new es6 conversion and #728 I found that it didn't help at all.
I've figured out a fix for it. The problem is in the PNG zlib decrypting. The doc.image() method is returning right away, and if you create a lot of pages and add a lot of images, the image processing piles up on itself until it's literally trying to decode hundreds of images at once. Unfortunately it seems the image decoding takes a few x more memory and when it happens all at once it gets out of hand.
With my fix, the 6 GB of memory went down to about 100 MB of memory. The downside though is that now doc.image() returns a promise instead of the doc, which means they can't be chained together anymore.
The text was updated successfully, but these errors were encountered: