-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
Hi,
When we are using this lib we found the readPngFileSync has a memory leak issue, try below code:
import libpng from "node-libpng";
const logMemoryUsed = () => {
const used = process.memoryUsage();
let usedString = '';
for (let key in used) {
usedString += `${key} ${Math.round(used[key] / 1024 / 1024 * 100) / 100}MB, `;
}
console.log(usedString);
};
const testMemory = () => {
const image = "test.png";
for (let i=0; i<200; i++) {
libpng.readPngFileSync(image);
logMemoryUsed();
}
};
testMemory()will get memory increasing heavily up to 1.62G as this:
...
rss 1556.95MB, heapTotal 8.95MB, heapUsed 6.13MB, external 31.12MB, arrayBuffers 7.07MB,
rss 1564.84MB, heapTotal 8.95MB, heapUsed 6.13MB, external 10.76MB, arrayBuffers 2.37MB,
rss 1572.74MB, heapTotal 8.95MB, heapUsed 6.13MB, external 10.76MB, arrayBuffers 2.37MB,
rss 1580.64MB, heapTotal 8.95MB, heapUsed 6.13MB, external 20.94MB, arrayBuffers 4.72MB,
rss 1588.53MB, heapTotal 8.95MB, heapUsed 6.13MB, external 31.12MB, arrayBuffers 7.07MB,
rss 1596.43MB, heapTotal 8.95MB, heapUsed 6.13MB, external 10.76MB, arrayBuffers 2.37MB,
rss 1604.32MB, heapTotal 8.95MB, heapUsed 6.13MB, external 10.76MB, arrayBuffers 2.37MB,
rss 1612.21MB, heapTotal 8.95MB, heapUsed 6.13MB, external 20.94MB, arrayBuffers 4.72MB,
rss 1620.11MB, heapTotal 8.95MB, heapUsed 6.14MB, external 31.12MB, arrayBuffers 7.07MB,
Could you help to check this issue since this node-libpng is quite useful to us, thanks.
Metadata
Metadata
Assignees
Labels
No labels