Hello I have a memory leak in node js that happens only in production mode on my vps which runs on a Ubuntu 18.04.3 LTS. In dev mode on Windows 10 this memory leaks does not occure. The code with problem on linux is the following:
async compressImage(
imageLocation: string,
outputWidth: number,
quality = 60,
):Promise<Buffer> {
try {
const file: any = await Jimp.read(imageLocation);
const buffer: Buffer = await file
.resize(outputWidth, Jimp.AUTO)
.quality(quality)
.getBufferAsync(Jimp.MIME_JPEG);
return buffer;
} catch (err) {
throw new Error(err);
}
}
This function runs in a for loop for 3 times.