You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I try to share a module instance for multiple image conversions, I end up getting out of bounds errors and nothing works, and if I make a new module instance for every image then there are no issues, but there are very big memory leaks that kill the process with enough conversions.
I am using Node if it matters.
// Sharing the same instanceletwebpModule: WebPModule|null=null;asyncfunctionencodeWebP(image: Jimp): Promise<Buffer>{if(!webpModule){webpModule=awaitwasm_webp();}// RuntimeError: memory access out of boundsconstresult=<Uint8Array>webpModule.encode(image.bitmap.data.buffer,image.getWidth(),image.getHeight(),4,defaultOptions);webpModule.free();returnBuffer.from(result);}
// New instance per imageasyncfunctionencodeWebP(image: Jimp): Promise<Buffer>{constwebpModule=awaitwasm_webp();// Works, but leaks memoryconstresult=<Uint8Array>webpModule.encode(image.bitmap.data.buffer,image.getWidth(),image.getHeight(),4,defaultOptions);webpModule.free();returnBuffer.from(result);}
If it's any help, when a new instance is created per image I eventually also get Node maximum listener warnings.
The text was updated successfully, but these errors were encountered:
I wonder if after running encodeWebP, keeping the Buffer.from result is keeping webpModule in memory. Try assigning webpModule to null in the second example after webpModule.free().
If I try to share a module instance for multiple image conversions, I end up getting out of bounds errors and nothing works, and if I make a new module instance for every image then there are no issues, but there are very big memory leaks that kill the process with enough conversions.
I am using Node if it matters.
If it's any help, when a new instance is created per image I eventually also get Node maximum listener warnings.
The text was updated successfully, but these errors were encountered: