Detecting memory leaks
Memory leaks can drastically reduce your application’s performance and can lead to crashes. V8 manages objects and dynamic data in its heap, a binary tree-based structure designed to manage parent-child node relationships. The V8 Garbage Collector (GC) is responsible for managing the heap. It reclaims any memory that is no longer in use – freeing the memory so that it can be reused.
A memory leak occurs when a block of memory is never reclaimed by the GC and is therefore idle and inefficient. This results in pieces of unused memory remaining on the heap. The performance of your application can be impacted when many of these unused memory blocks accumulate in the heap. In the worst cases, the unused memory could consume all the available heap space, which, in turn, can cause your application to crash.
In this recipe, we’ll learn how to use Chrome DevTools to profile memory, enabling us to detect and fix memory leaks.