![phpstorm nodejs phpstorm nodejs](https://www.bulblub.com/wp_uploads/2013/05/meteor-server_remote_debug_settings.png)
referenced from the code that is executed right now), objects that belong to the JavaScript engine, such as compilation cache, and objects backed by native (non-JavaScript) objects. GC roots include objects in the current call stack (i.e.
![phpstorm nodejs phpstorm nodejs](https://www.devinuk.com/wp/wp-content/uploads/2016/10/phpstorm-scss-file-watcher.png)
Hence, they are used as a starting point to determine which objects can be collected.
![phpstorm nodejs phpstorm nodejs](https://www.speich.net/wp/wp-content/uploads/2016/04/step02.gif)
How does Garbage Collector (GC) determine that an object is not needed? There is a special group of objects, called GC roots that are known to exist. Taking a heap snapshot in this case will help us find out which of the queues or caches run “out of the budget.” It may result in running out of memory or frequent garbage collection invocations. Our application operates a limited amount of memory, and big data structures such as caches or queues may eventually consume a significant part of memory. The three main concepts around application memory management are memory budget, memory leaks, and the speed of memory consumption. Node.js servers tend to run for a long time, so any memory leaks would accumulate over time. Memory problems are especially dangerous for Node.js applications. That is why it’s important to use an optimal memory consumption strategy and, of course, watch out for errors. The application is responsible for the object lifecycle. So why should we then care about memory profiling? Although memory is allocated, freed, and defragmented automatically, it is still our application code that requests object creation, and the application should indicate when objects are not needed. only about the memory area that is managed by the JavaScript engine and contains JavaScript objects. In this article we will talk about the V8 JavaScript heap, i.e. Node.js, io.js, and Google Chrome use the same open-source JavaScript engine, called V8. That means that the JavaScript engine itself takes care of allocating space for your objects and collecting objects when they are not needed. JavaScript is a language with automatic memory management.