npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-red-contrib-heap-dump

v0.0.2

Published

A Node Red node to create a heap dump file

Downloads

108

Readme

node-red-contrib-heap-dump

A Node Red node to create a heap dump file.

Install

Run the following npm command in your Node-RED user directory (typically ~/.node-red):

npm install node-red-contrib-heap-dump

Support my Node-RED developments

Please buy my wife a coffee to keep her happy, while I am busy developing Node-RED stuff for you ...

Node Usage

When talking about garbage collections in NodeJS, the collections are executed in the V8. That V8 is Google's Javascript engine (written in C++), that is a.o. used to run Node.js.

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:

  1. Specify a directory in the node's config screen, where the heap dump file <timestamp>.heapsnapshot will be generated.

  2. 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 msg.directory field).

  3. The node status will indicate that the node is currently creating a heap dump:

    Trigger heap dump

  4. When the heap dump is finished, the node status will display the full path of the heap dump file:

    Heap dump done

  5. Execute some actions in Node-Red, preferable actions that you suspect causing the memory leak.

  6. Create on or more extra heap dumps, i.e. repeat steps 1 to 4 a number of times.

  7. Compare the heap dumps, e.g. using Chrome developer tools.

  8. Analyze the delta between the heap dumps ...

Example flow:

[{"id":"194b13aa.03f90c","type":"heap-dump","z":"15244fe6.9ae87","directory":"/tmp/bart","createDir":true,"name":"","x":1120.1668167114258,"y":325.33335304260254,"wires":[[]]},{"id":"535cf64a.826208","type":"inject","z":"15244fe6.9ae87","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":945.166748046875,"y":325.66668701171875,"wires":[["194b13aa.03f90c"]]}]