Tri-Color Marking Process in JavaScript Garbage Collection

Added:

Tri-Color Basics
Marking Workflow
Visual Example
Incremental & Barrier
Parallel & Concurrent
Final Wrap-Up

Tri-Color Basics

0:00
Playing Section
  • 1

    Defines Tri-Color marking with white, gray, black object states.

  • 2

    Explains how each color signals reachability and GC action.

Fundamental concepts of heap and stack memory allocation in modern programming runtimes.
The basic Mark-and-Sweep garbage collection algorithm and the concept of 'Stop-the-World' pauses.
Graph theory basics, specifically representing program objects and their references as directed graphs with root nodes.
JavaScript's single-threaded execution model and the event loop, to understand why blocking GC phases degrade performance.
V8's generational garbage collection architecture, specifically the division between the Minor GC (Scavenger) and Major GC.
Advanced memory profiling and diagnosing memory leaks in JavaScript using Chrome DevTools Heap Snapshots and Allocation Timelines.
Coding patterns for memory optimization, such as using Object Pools, managing closure scopes, and avoiding detached DOM nodes.
Comparative analysis of concurrent and parallel garbage collection algorithms across other runtimes, such as the JVM or Go's runtime.
317 views13likes12:26@DecodeWebWithRohanOriginal Release: 2024-04-07

Tri-Color Marking is a garbage collection algorithm where each object is marked with three colors: white (unvisited, considered dead), gray (visited but references not yet examined, considered dead), and black (fully visited with all references examined, considered live). The algorithm begins by marking root objects as gray and adding them to a work list, then iteratively processes nodes by marking them black and examining their references to mark neighboring objects as gray. V8 enhances this with incremental marking (splitting work into chunks to minimize pauses), write barriers (maintaining the invariant when object structures change during execution), and parallel/concurrent marking (using multiple threads to share marking work).