Skip to content
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

Improving memory usage for PDF files loaded by chunks #5329

Closed
bh213 opened this issue Sep 23, 2014 · 5 comments
Closed

Improving memory usage for PDF files loaded by chunks #5329

bh213 opened this issue Sep 23, 2014 · 5 comments
Labels

Comments

@bh213
Copy link

bh213 commented Sep 23, 2014

When file is loaded using pdfDataRangeTransport ChunkedStream will allocate memory for the whole file. In our case opening 1.9GB PDF file crashed practically every browser except 64-bit Chrome and even that one had 50-50 chance of crashing.

I have refactored ChunkedStream to use non-continuous memory. Reading (but not displaying) the same file now consumes 50MB or so. My commit is here:

bh213@161218e

I've added unit tests and the code passes all the tests. Still, I am not sure this is ready for pull request yet. There is no eviction (even though it is trivial to implement) and I'd like a review of both of my one line changes to core.js and worker.js. I haven't done any pull requests before so I probably did something else wrong too.

@yurydelendik
Copy link
Contributor

Thank you for looking into this. This is great (especially added testing). It's really hard to provide a feedback for a change that is not submitted as a pull request. When you decide to submit PR, make sure you are touching only the code that really needs to be changed, e.g. a reviewer will have a hard time understanding why you changed formatting at ChunkedStreamManager_onProgress under this change. See also https://github.com/mozilla/pdf.js/wiki/Contributing and https://github.com/mozilla/pdf.js/wiki/Style-Guide.

@bh213
Copy link
Author

bh213 commented Sep 23, 2014

I did read up on style & contribution guide and made lint & tests pass. Guide said to contact maintainers before creating a PR so this is what I am doing. :)
btw, onProgress update is there by mistake I did while fixing lint errors. Let me fix that and then submit PR?

@Snuffleupagus
Copy link
Collaborator

One issue, style wise, with your patch is that you have indented with tabs in many places. Please replace all of them with spaces instead, before submitting the PR.
Also, probably related to the usage on tabs, you have (incorrectly) changed the indentation level in many places (e.g. here), please revert all of those changes. This will make the diff smaller and thus easier to review.
There also appears to be a number of unnecessary new lines inserted in existing code in many places, please revert those as well, to further reduce the size of the patch.

Edit: As noted above, you should always avoid touching lines not directly related to the patch. This makes life easier for the reviewer, and should reduce the time it takes to review your patch! :-)

@bh213
Copy link
Author

bh213 commented Sep 23, 2014

Updated styling, created PR.

@Snuffleupagus
Copy link
Collaborator

Closing as, mostly a, duplicate of issue #5304.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants