Garbage collection
JavaScript is a garbage collected language. What that means is that a JavaScript engine will occasionally fire something called a garbage collector, which looks for unused and inaccessible references in memory for the program and clears them, making the memory available for storing other data.
Garbage collectors make life a lot easier, but add a bit of overhead in performance-critical applications. Say you are coding a 3D game where you want very high Frames Per Second (FPS) on not so good hardware.
You might see that the results are extremely good for a game coded in C/C++, as compared to a garbage collected language like Java. This is because when you're playing the game, garbage collectors might fire off even when it ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access