Skip to content

Using typed array instead of native JS array#139

Merged
meltingice merged 1 commit intomeltingice:masterfrom
rtf-const:typed_array
Jun 11, 2018
Merged

Using typed array instead of native JS array#139
meltingice merged 1 commit intomeltingice:masterfrom
rtf-const:typed_array

Conversation

@rtf-const
Copy link
Copy Markdown

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
Copy Markdown
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.

3 participants