Suspected memory leak
See original GitHub issueMy server uses chartjs-node-canvas to generate many charts into a pdf. I ran the chrome heap profiler and noticed that each time I generate the report, I get a significant amount of chart related records with high retained sizes. Below are the screenshots:
Code usage:
rangeLine(min, max, value).then(chart => {
...
});
const rangeLine = (min, max, val) => {
const canvasRenderService = new CanvasRenderService(170, 30);
return canvasRenderService.renderToBuffer({
type: "line",
data: {
datasets: [
{
pointBackgroundColor: "white",
borderColor: "black",
data: [
{
x: min,
y: 0
},
{
x: mid,
y: 0
},
{
x: max,
y: 0
}
]
},
{
pointBackgroundColor: 'blue',
pointRadius: 10,
pointStyle: "rectRot",
data: [
{
x: val,
y: 0
}
]
}
]
}
});
};
Version: v2.4.0
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Java Memory Leaks: Solutions, Tools, Tutorials & More - Stackify
We put together this guide to help you understand how, why, and where Java memory leaks happen – and what you can do...
Read more >Hunting Java Memory Leaks - Toptal
A memory leak occurs when object references that are no longer needed are unnecessarily maintained. These leaks are bad. For one, they put...
Read more >Java Memory Leak Detection: Causes & Tools to Avoid Them
The memory leak is a situation where an object or objects are no longer used, but at the same time, they can't be...
Read more >How to Fix A Windows Memory Leak - Lifewire
The steps below show how to view your system's memory usage in Windows 10, 8, and 7. Press Windows key+R, enter "resmon," then...
Read more >Creating a Memory Leak Diagnosis report - IBM
In the Memory Leak Diagnosis report each row in the Suspected Memory Leaks table represents an allocation pattern for which memory allocation data...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi seth.
freshRequire
is needed to isolatecanvas
instances since actions in the library’s API mutate global state inside, canvas width and height for example. This way eachCanvasRenderService
encapsulates that state for you, at the cost of a bit of complexity with things like chart plugins, fonts etc.The code you mention does actually appear like a bug, but could possibly be done that way for some reason. I will investigate more tomorrow to confirm but yeah looking at it I can’t think of why there would be separate instances for font and the canvas.
Thank you, Sean.