zstd-codec
zstd-codec copied to clipboard
RangeError: WebAssembly.Memory(): could not allocate memory
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;
}