Possible memory leak
Closed this issue · 3 comments
qwertyforce commented
const imghash = require('imghash');
const axios = require('axios');
function log_mem() {
const used = process.memoryUsage();
for (let key in used) {
console.log(`${key} ${Math.round(used[key] / 1024 / 1024 * 100) / 100} MB`);
}
}
async function get_phash(url){
let pic = await axios.get(url,{responseType: 'arraybuffer'})
const phash = await imghash.hash(pic.data, 16)
return phash
}
const urls=["https://upload.wikimedia.org/wikipedia/commons/f/ff/Pizigani_1367_Chart_10MB.jpg","https://upload.wikimedia.org/wikipedia/commons/e/e6/Clocktower_Panorama_20080622_20mb.jpg"]
async function run(){
const x = await get_phash(urls[0])
console.log(x)
const x2 = await get_phash(urls[1])
console.log(x2)
}
setInterval(function() {
console.log("timer that keeps nodejs processing running");
console.log("======================================")
console.log("before gc")
log_mem()
gc()
console.log("======================================")
console.log("after gc")
log_mem()
console.log("======================================")
}, 1000 * 10);
run()
1f601ef03ef03ee01ee03fe03fc07ec03e003fc07fe07fc07fc07fc07fc03e00
timer that keeps nodejs processing running
======================================
before gc
rss 623.58 MB
heapTotal 6.96 MB
heapUsed 5.73 MB
external 586.12 MB
arrayBuffers 297.17 MB
======================================
after gc
rss 608.74 MB
heapTotal 7.21 MB
heapUsed 4.85 MB
external 586.12 MB
arrayBuffers 19.8 MB
======================================
f801f801f827fc2ff81ffc37fc037000fbd8a1ea01e203fcb3fc03e007f03be4
timer that keeps nodejs processing running
======================================
before gc
rss 570.23 MB
heapTotal 7.21 MB
heapUsed 5.03 MB
external 517.87 MB
arrayBuffers 228.92 MB
======================================
after gc
rss 541.74 MB
heapTotal 7.21 MB
heapUsed 4.69 MB
external 517.87 MB
arrayBuffers 15.4 MB
======================================
timer that keeps nodejs processing running
======================================
before gc
rss 338.11 MB
heapTotal 6.21 MB
heapUsed 4.68 MB
external 288.98 MB
arrayBuffers 0.03 MB
======================================
after gc
rss 338.12 MB
heapTotal 6.21 MB
heapUsed 4.53 MB
external 288.98 MB
arrayBuffers 0.03 MB
======================================
timer that keeps nodejs processing running
======================================
before gc
rss 338.12 MB
heapTotal 6.21 MB
heapUsed 4.63 MB
external 288.98 MB
arrayBuffers 0.03 MB
======================================
after gc
rss 338.1 MB
heapTotal 6.21 MB
heapUsed 4.52 MB
external 288.98 MB
arrayBuffers 0.03 MB
======================================
pwlmaciejewski commented
After a quick investigation, it looks like an issue with imageFromBuffer
from https://github.com/node-gfx/image.
I need to dig deeper tho.
\cc @LinusU
stale commented
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
stale commented
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.