jsreport by default reuses chrome instances
https://jsreport.net/learn/chrome-pdf#chrome-process-allocation
The nodejs is garbage collected runtime. It will clear the memory when it "gets the mood".
To test the memory leaking, give the pod or container limited memory like I recommended, and then test in the loop.
I've tried now the leak test and I don't see it would be getting out of bounds.
Start jsreport with just 300mb
docker run -p 5488:5488 -d -m=300m jsreport/jsreport:4.4.0
Then render 10 000 pdfs => no OOM.
I'm not saying there is no memory leak, but we will need to deterministically replicate it to be able to localize it.
const client = require('@jsreport/nodejs-client')('http://localhost:5488')
async function runOne () {
const r = await client.render({
template: {
name: 'invoice-main'
},
data: {
"number": "123",
"seller": {
"name": "Next Step Webs, Inc.",
"road": "12345 Sunny Road",
"country": "Sunnyville, TX 12345"
},
"buyer": {
"name": "Acme Corp.",
"road": "16 Johnson Road",
"country": "Paris, France 8060"
},
"items": [{
"name": "Website design",
"price": 300
}]
}
})
return r.body()
}
async function runMany() {
for (let i = 0; i < 2000; i++) {
console.log(i * 5)
await Promise.allSettled([runOne(),runOne(),runOne(),runOne(),runOne()])
}
}
runMany().then(() => console.log('done')).catch(console.error)