Skip to main content

Node Garbage Collection

Garbage Collection

Garbage collection (GC) can have a big impact on the performance of your apps. GC is a process that the Node.js runtime regularly runs to clean up any objects that were created and are not used anymore.

If you create a lot of objects in your code (or a dependency does) this can slow down your app. It’s therefore a good idea to keep an eye on this. We shipped GC magic dashboard to make this easy for you!

Once you upgrade your node package to 1.2.0 and deploy your app a new Node.js Heap Statistics dashboard will appear. Let’s look at what data is on the dashboard!

Heap Statistics

Node.js reserves memory to store your objects in. This is called the “heap”. The top graph in the dashboard displays the total size of your heap, and how much of it is used.

Heap statistics

If you see a lot of variation here that’s an indication something might be off. In this screenshot we put some load on this test app, and then stopped requesting pages for a bit. You can clearly see that the Node.js runtime reacted to this by making the heap smaller.

If you see this graph steadily increasing there might be a memory leak in your code, or in a dependency.

Contexts

The second graph on this dashboards show the number of currently active top-level contexts. This number should regularly stay stable, otherwise this would indicate a potential memory leak.

Native contexts

The third graph shows the number of contexts that were detached and not yet garbage collected. If this number is not zero you might have a memory leak to deal with.

Detached contexts

Comments

Popular posts from this blog

These Are The Bash Shell Commands That Stand Between Me And Insanity

These Are The Bash Shell Commands That Stand Between Me And Insanity These Are The Bash Shell Commands That Stand Between Me And Insanity I will not profess to be a bash shell wizard… but I have managed to scour some pretty helpful little scripts from Stack Overflow and modify… These Are The Bash Shell Commands That Stand Between Me And Insanity I will not profess to be a bash shell wizard… but I have managed to scour some pretty helpful little scripts from Stack Overflow and modify them to suit my needs. All of these commands are for Ubuntu/WSL … some may work in other scenarios but I can’t guarantee it.
Deploy-React-App-To-Heroku-Using-Postgres Deploy React App To Heroku Using Postgres & Express Heroku is an web application that makes deploying applications easy for a beginner. Deploy React App To Heroku Using Postgres & Express Heroku is an web application that makes deploying applications easy for a beginner. Before you begin deploying, make sure to remove any console.log ’s or debugger ’s in any production code. You can search your entire project folder if you are using them anywhere. You will set up Heroku to run on a production, not development, version of your application. When a Node.js application like yours is pushed up to Heroku, it is identified as a Node.js application because of the package.json file. It runs npm install automatically. Then, if there is a heroku-postbui

Data Structures Resources

Data Structures & Algorithms Resource List Part 1 Data Structures & Algorithms Resource List Part 1 Guess the author of the following quotes: Data Structures & Algorithms Resource List Part 1 Guess the author of the following quotes: Talk is cheap. Show me the code. Software is like sex: it’s better when it’s free. Microsoft isn’t evil, they just make really crappy operating systems. Update: Here’s some more: