Skip to content

Size limit for gzip decompression #30

Answered by 101arrowz
mvallet91 asked this question in Q&A
Discussion options

You must be logged in to vote

There's a hard limit on how big a single typed array can be. 2.1 GB is roughly the 231 byte limit that exists in all browsers for all typed arrays. Remember that you're housing 2.1 GB of data in memory at once.

Your use seems perfect for streaming the data in one chunk at a time.

let reader = new FileReader();

reader.onload = function(event) {
  const buffer = new Uint8Array(event.target.result);
  let totalLines = 0;
  const strm = new fflate.AsyncDecompress((err, dat) => {
    // If this is all standard ASCII:
    const stringContent = fflate.strFromU8(dat);
    totalLines += stringContent.split('\n').length;
  });
  let i = 0;
  for (; i < buffer.length - 512000; i += 512000) {
    strm.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by mvallet91
Comment options

You must be logged in to vote
1 reply
@mvallet91
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants