Video series · 2 parts

Memory Management in Go

How Go decides whether data lives on the stack or the heap, and how its garbage collector manages and is tuned for heap memory.

Go has a garbage collector, so you rarely think about memory, but knowing where your data lives helps you write faster programs. Part 1 covers the stack and the heap, and how the compiler's escape analysis decides which one each variable goes on.

Part 2 is about the garbage collector itself. It marks and sweeps concurrently while your program runs, and it doesn't split the heap into generations. I explain why: the compiler already keeps most short-lived values on the stack, so generations would buy Go very little.

  1. Part 1
    Memory Management in Go - Part 1 thumbnail
    YouTube

    Memory Management in Go - Part 1

    Go runs a garbage collector, but underneath that every variable ends up either on the stack or the heap, and the compiler chooses using escape analysis.

    Watch →
  2. Part 2
    Memory Management in Go - Part 2 thumbnail
    YouTube

    Memory Management in Go - Part 2

    I break down how Go’s garbage collector works: it’s non-generational, concurrent, and uses a tricolor mark-and-sweep algorithm.

    Watch →

Read next

Hassan Aziz pointing up

Dude, you’re at the bottom of my landing page.

Just book a call already if you’re that interested.

You scrolled all the way here.

Book a free call on Calendly