Node.js Garbage Collection

0.0(0)
studied byStudied by 0 people
0.0(0)
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/14

flashcard set

Earn XP

Description and Tags

Last updated 12:23 PM on 2/4/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

15 Terms

1
New cards

What is the core concept V8 uses to determine if memory can be freed?

Reachability; meaning objects that cannot be reached from the Root are considered garbage

2
New cards

What are the two primary generations in the V8 Heap structure?

The Young Generation (New Space) and the Old Generation (Old Space)

3
New cards

Which algorithm is used for Major Garbage Collection in the Old Space?

Mark-Sweep-Compact

4
New cards

What is the name of the algorithm used for Minor GC in the Young Generation?

Scavenge (using the Cheney algorithm)

5
New cards

What defines a "Root" in JavaScript memory management?

Global objects; local variables in the current stack frame; and internal V8 handles

6
New cards

What happens to an object in the Young Generation if it survives two Scavenge cycles?

It is promoted (tenured) to the Old Generation

7
New cards

What is a "Stop-the-World" event in Garbage Collection?

A pause where the main program execution halts completely so the Collector can process memory safely

8
New cards

How does Incremental Marking improve application performance?

It breaks the marking phase into small chunks interleaved with JavaScript execution to avoid long pauses

9
New cards

What is a memory leak?

When objects are no longer needed by the application but are still referenced by the Root; preventing GC from removing them

10
New cards

Which Node.js flag is used to increase the heap size limit for the Old Generation?

--max-old-space-size

11
New cards

What is the special behavior of WeakMap keys regarding Garbage Collection?

The keys are weakly referenced; allowing them to be garbage collected if no other strong references exist

12
New cards

What are the three distinct phases of a Major GC cycle?

Marking (identifying live objects); Sweeping (freeing dead memory); and Compacting (defragmenting)

13
New cards

Why is the Young Generation kept small (typically 1-8MB)?

Because most objects die very quickly ("The Generational Hypothesis"); making a small space efficient for frequent cleanup

14
New cards

What role does the "Write Barrier" play in GC?

It records references from the Old Generation to the Young Generation so the Scavenger doesn't have to scan the entire Old Heap

15
New cards

Which tool is most commonly used to debug memory leaks in Node.js?

Heap Snapshots (via Chrome DevTools or the v8-profiler)