Book Image

Node.js High Performance

By : Diogo Resende
Book Image

Node.js High Performance

By: Diogo Resende

Overview of this book

Table of Contents (14 chapters)

Automatic memory management


GC tremendously simplifies language usage, giving developers more time to focus on other aspects of the application. Also, it can reduce, although not completely remove, a type of error called memory leaks, which haunt long-lived applications and services. However, there's a performance penalty associated with its periodic task. It can be noticed, or not, depending on how much memory is used and disposed in short periods of time.

By moving memory management out of the developer, Node.js removes or substantially reduces a few types of bugs:

  • Dangling pointer bugs: These occur when memory is freed but still there are one or more pointers referencing that the memory blocks. If the memory is reassigned, these pointers can cause unpredictable behavior if used to change blocks from other parts of the program. You would have, in this case, more than two places in the application changing the same memory block. This is a particularly difficult bug to find.

  • Double free bugs...