Possible Memory Leak?
Author: robacaCreated Jul 22, 2020Updated Dec 16, 2024
We are using the d3 module 1.23.1 to create thumbnails for images with code like the following:
this.gm(originalStream, 'someImage.jpg')
.options({ timeout: 15000 })
.autoOrient()
.unsharp(0, 0.5)
.resize(250, 500, '>')
.stream('jpg', (err: Error, stdout: any) => {
if (err) {
return reject(err)
}
const someOutputStream = // create output stream
stdout
.pipe(someOutputStream)
.on('finish', resolve)
.on('error', reject)
})When calling this code multiple times, it seems that d3 stores some buffer references and we have get a memory leak. This is how a diff between two heapsnapshots looks like:

Do we have to do some cleanup to finally free resources?
Source: aheckmann/gm