zstd-codec icon indicating copy to clipboard operation
zstd-codec copied to clipboard

RangeError: WebAssembly.Memory(): could not allocate memory

Open varyzheng opened this issue 3 years ago • 0 comments

I'm using zstd-codec v0.1.2 in nodejs, and after decompressed about 100 times, it will throw this exception. Maybe there is a memory leap in my code, but I don't know the reason.

const ZstdCodec = require('zstd-codec').ZstdCodec;
export const decompress = (buffer: Buffer): Promise<Buffer> => {
  return new Promise((resolve) => {
    ZstdCodec.run((zstd) => {
      const simple = new zstd.Simple();
      const data = simple.decompress(buffer);
      resolve(data);
    });
  });
};

And I call this function in other module like this:

import { decompress } from './util';
async function dec (buffer) {
  const afterDecompress =  await decompress(buffer);
  return afterDecompress;
}

varyzheng avatar Nov 26 '21 06:11 varyzheng