← Back

The Heap Was Always There, I Just Never Had to Care

· 5 min read

Up until 2026, I’d mostly lived in the high-level language world: Python, JavaScript/TypeScript, Java and friends. These languages hide a lot from you as a developer, and that convenience comes at a cost. The funny part is that in about 90% of situations you’d never notice, because modern hardware is just that powerful. This year, though, I decided to dive into low-level systems programming, and I quickly realized how far out of my depth I was. One of the first things that tripped me up on my journey to becoming a cracked gigachad low-level programmer was the heap: what it is, and why I’d never felt its importance in all my years of coding.

In most languages, compiled or interpreted, like JavaScript, Python, Go and Java, “memory is managed for you.” If you’re anything like me, you’ve heard that line thrown around in dev communities a hundred times without ever really understanding HOW. It turns out these languages have a little helper process running alongside your code, keeping an eye on your data and making decisions so your program runs smoothly without eating up all your RAM. This helper is called the garbage collector (GC for the cool kids), and its job comes down to two things:

  1. Deciding whether an object (a primitive like an int or float, or something bigger like a class, struct or object) goes on the stack or the heap. The main thing it looks at is how big that object is.
  2. Since memory is finite, cleaning up objects that have gone out of scope and can never be reached again while the program runs.

The garbage collector borrows little slices of time while your program runs to do this work, kind of like a sous chef tidying up the head chef’s station while the head chef keeps cooking for customers.

The stack and the heap

When a process starts, the OS gives it a chunk of RAM to work with, its own scratch pad. That memory is split into a few sections, but the two we care about are the stack and the heap. The stack is reserved for function calls, their arguments, and the local variables inside whatever function is currently running. The key difference between the stack and the heap is size. The stack only holds a few megabytes, which makes sense since it’s only meant for the call stack and a handful of local variables. The heap, on the other hand, can grow and hold large amounts of data because it isn’t boxed in like the stack. Think of it as a big storage yard for larger things, basically your gateway to RAM itself. Like I said earlier, part of the GC’s job is to look at your program while it runs and decide when something is too big for the stack and needs to go on the heap, before it overflows the stack (yes, that’s where “stack overflow” comes from :) ). All the languages I listed give us this luxury, which is exactly why I never noticed the heap existed or why it mattered.

Life without a garbage collector

In low-level languages, this helpful little process doesn’t exist at all. You might be wondering why. If it gives us so much and saves us from thinking about allocating and freeing memory, why not have it everywhere? The answer is simple: the garbage collector costs performance. In about 90% of the apps and systems you’ll ever build, you don’t need consistent sub-millisecond performance, and there’s plenty of room for small hiccups in your performance numbers. That’s why most software can live with a GC just fine. But there are environments where a GC sticks out like a sore thumb, like games and game engines or high-speed trading software. That’s where non-GC languages like C, C++ and Rust really shine. Take games, for example. A common target for smooth gameplay is 60fps, which means your game has to push a new frame to the screen every 16ms, every single time, without fail. If something bumps that up to 17ms or 20ms, your frame rate drops and gamers won’t be happy. Those extra 2–5ms are roughly how long a garbage collector might take to do its thing, so in a GC language you’d see lag spikes every time the GC kicks in.

So that’s why a lot of beginner programmers never learn about the heap or even know it exists: they simply don’t need to. Most software isn’t that constrained or performance-critical, so you could honestly go your whole career without learning this stuff because the need never comes up. But in tight environments like games or trading software, a few milliseconds can be the difference between landing a kill or not, or between making a risky, lucrative trade or getting liquidated. Those margins can’t be left to the unpredictable timing of a garbage collector, so developers have to take responsibility for managing heap memory themselves.