A Node Red node to create a heap dump file
A Node Red node to create a heap dump file.
Run the following npm command in your Node-RED user directory (typically ~/.node-red):
npm install node-red-contrib-heap-dump
In normal circumstances, the V8 engine will cleanup memory (using garbage collections) as soon as necessary. But sometimes the garbage collections run frequently, but they don't cleanup all unused data from memory. Some memory keeps being allocated, despite it is not being used anymore. As a result, the memory usage start increasing... This situation is called memory leakage.
To find the root cause of a memory leak, you will need to compare multiple heap dumps (e.g. using the Chrome developer tools). This analysis process isn't explained here, because tons of tutorials about it can be found on the internet.
A heap dump is a snapshot of the NodeJs heap memory at a certain moment in time. This node simplifies the process of creating heap, since it is fully integrated in your Node-Red flow:
Specify a directory in the node's config screen, where the heap dump file
<timestamp>.heapsnapshotwill be generated.
Inject a message into the heap dump node. When no directory has been specified in step 1, a directory can be specified in the input message (using the
The node status will indicate that the node is currently creating a heap dump:
When the heap dump is finished, the node status will display the full path of the heap dump file:
Execute some actions in Node-Red, preferable actions that you suspect causing the memory leak.
Create on or more extra heap dumps, i.e. repeat steps 1 to 4 a number of times.
Compare the heap dumps, e.g. using Chrome developer tools.
Analyze the delta between the heap dumps ...