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

Using typed array instead of native JS array #139

Merged
merged 1 commit into from
Jun 11, 2018

Conversation

rtf-const
Copy link

Current implementation uses native JS arrays for store layers image data. But JS arrays is very inefficient for store large binary data. I replaced them with Uint8Array. It is supported by all modern browsers as well as by NodeJS. It provides significant performance gain.
I used following psd file for testing https://drive.google.com/open?id=1LgGiHPgbr9Vrc7j0DCvXDSlFBBk5AmB5
Original version in my PC is trying to allocate about 1.5 GB of RAM and then it die with "JavaScript heap out of memory" error. See also the issue #135

My version uses less than 400 MB of RAM and it loads file successfully.

I have to apologize but this PR also contains code for my previous PR #117 that isn't merged yet. But in my project I need both ability to work with mask data and working with large PSD files (100 MB and more) so I cannot easlty separate them

@meltingice meltingice merged commit 38a26b5 into meltingice:master Jun 11, 2018
@meltingice
Copy link
Owner

Great find, thanks!

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

Successfully merging this pull request may close these issues.

None yet

3 participants