Question 01Answers in Raw Mode
A strong answer walks through bump-pointer allocation in a generational heap and can predict which allocation patterns actually become expensive
Senior
How bump-pointer allocation really works, the two semi-spaces hiding behind new space, the two-scavenge promotion rule, and which values even allocate at all (Smis ride inside the tagged pointer itself).
Staff
Why allocation rate decides your scavenge cadence, the mid-lived object pattern that quietly taxes throughput under load, and the v8.getHeapSpaceStatistics numbers which give it away.
Follow-up chain
- Okay, so why is allocating in new space so cheap in the first place?
- Given that design, what's the worst allocation pattern you could feed it?
- Say that pattern is happening in a running service right now. How will you spot it?
- Quick one. Do numbers even allocate on the heap?
Question 02Answers in Raw Mode
Strong candidates tie each collector's algorithm to its pauses, weigh copying cost against marking cost, and know what modern V8 actually runs concurrently
Senior
The two cost models behind copying and marking, what Orinoco actually moved off the main thread, and the write barriers that keep concurrent marking honest.
Staff
How to read gc performance entries and blame the right collector, what GC thrash near the heap limit looks like, and the heap-headroom tradeoff nobody sizes properly.
Follow-up chain
- Hang on, why does a scavenge cost you for the live data and nothing for the garbage?
- Say throughput drops 30 percent, no OOM, and downstream latency is flat. How could that possibly be GC?
- What numbers would you pull to prove it's GC thrash, and where's the line where you act?
- So in current V8, what actually still stops the world?
Question 03Answers in Raw Mode
You can tell a strong answer because they've actually walked a retainer path in a snapshot diff and know what a snapshot costs on a big live process
Senior
The three-snapshot diff workflow, how you actually read a retainer path back from a GC root, and the handful of leak shapes behind most real incidents.
Staff
How snapshotting a hot pod turns a debugging session into an outage, the near-heap-limit and canary tricks that work instead, and the trend monitoring that catches leaks before anyone gets paged.
Follow-up chain
- What if heapUsed stays flat but RSS keeps climbing? Where do you go looking then?
- Alright, you've got the snapshot open in front of you. Walk me through actually reading a retainer path.
- The chain runs through something called 'context'. What's that telling you?
- Suppose a snapshot pause is just too long for your traffic. What do you reach for instead?
Question 04Answers in Raw Mode
A good answer keeps the V8 heap limit separate from total process memory and sizes both against the cgroup limit with honest headroom
Senior
Everything RSS holds beyond the JS heap, external buffers, thread stacks, code, allocator slack, plus how to tell the two OOM signatures apart by their exit codes.
Staff
The headroom arithmetic you'd actually run for a real service, the GC thrashing that shows up near the limit, and keeping the flag in lockstep with the cgroup at the entrypoint.
Follow-up chain
- You see exit code 137 one day and a 'JavaScript heap out of memory' abort the next. What's each one telling you?
- Why leave 25 percent on the table between the heap limit and the container limit?
- And in a typical API service, what's actually eating that headroom?
Question 05Answers in Raw Mode
Strong answers know capture is per-variable into a heap context, and that closures born in one scope share it, the mechanism behind the classic pin
Senior
How contexts get allocated, which variables end up on the heap versus the stack, and the shared-context rule that lets one surviving callback pin a sibling's data.
Staff
The long-lived-emitter registration mistake behind most closure leaks in services, what it looks like in a heap snapshot, and the narrow-capture refactors that actually fix it.
Follow-up chain
- So two closures come out of the same function scope. How does one end up keeping the other one's data alive?
- And when you're staring at a heap snapshot, what does that actually look like?
- What's the smallest change you could make that breaks the retention without restructuring the module?
Question 06Answers in Raw Mode
A strong answer explains shape-based access and IC transitions with the actual cost model, and knows where shape pollution comes from in real services
Senior
Maps and transition trees, the IC states from monomorphic through megamorphic with the real lookup cost at each tier, and what dictionary mode actually does.
Staff
Where shape pollution really comes from in API services (rows, optional fields, mutating middleware), the profiling workflow that finds it, and when to just leave it alone.
Follow-up chain
- Walk me through what actually happens when a megamorphic site loads a property.
- How would you hunt down a shape problem in a real service, not a microbenchmark?
- That IC trace output is a wall of text at any real scale. What's the workflow that actually works?
- Why would adding the exact same properties in a different order give you a different hidden class?
Question 07Answers in Raw Mode
Good answers map every process.memoryUsage() field to its allocator, know Buffer bytes live outside the V8 heap, and can explain slab retention and slack
Senior
The full RSS ledger walked field by field, how Buffer pooling and slab retention really work, and why a 10-byte slice can pin an entire 64KiB allocation.
Staff
The slice-retention incident that keeps hitting proxies, the glibc arena behavior that holds RSS at peak long after a spike, and MALLOC_ARENA_MAX as the container fix.
Follow-up chain
- Say you keep a small slice of every network read that comes in. What does that do to memory?
- And how would you prove it's slice retention, from metrics or a snapshot?
- The traffic spike ends, usage drops, and RSS just sits there at peak. Why?
- Does Buffer memory even register with the garbage collector at all?
Question 08Answers in Raw Mode
A strong candidate prices a big `JSON.parse` across loop time, allocation spike, and string representation, then designs the payload path around all three
Senior
The three-stage bill for buffer-to-string decode, the synchronous parse, and the object-graph blowup, plus the string internals (ropes, sliced strings) behind surprise retention.
Staff
Why the worker-thread instinct mostly fails here, the protocol-level fixes that actually hold up, and the ingress caps that make a 100MB body impossible by design.
Follow-up chain
- Where does all that object-graph blowup actually come from?
- What if I just move the JSON.parse into a worker thread? Does that fix it?
- Okay, so what would you do instead? Give me something concrete.
- How does keeping one little substring of a huge string end up leaking the whole thing?
Question 09Answers in Raw Mode
Strong answers place WeakMap, WeakRef, and FinalizationRegistry by their GC semantics, and know finalization timing is unspecified and can't carry cleanup
Senior
The ephemeron semantics that make WeakMap cycles safe, why the whole WeakRef lifecycle comes down to one deref, and exactly what finalization does and doesn't promise.
Staff
The one pattern where WeakMap is genuinely the right tool, metadata on objects you don't own, why explicit lifecycle beats weakness for caches, and finalizers as leak detectors.
Follow-up chain
- Why did they leave iteration and size off WeakMap on purpose?
- What if a WeakMap value points back at its own key? Did I just build a leak?
- Why can't I just let a FinalizationRegistry close my file descriptors?
- So what's the right pattern for native handles then?
Question 10Answers in Raw Mode
A strong answer treats deoptimization as a failed speculation guard and can name the tools that make bailouts visible on real code
Senior
The speculate-guard-bailout cycle across V8's compiler tiers, the concrete trigger list, and what actually separates an eager deopt from a lazy one.
Staff
The deopt-loop pathology and how V8 defends itself, how to read --trace-deopt and Deopt Explorer output, and when the hunt is even worth staff time.
Follow-up chain
- You mentioned eager and lazy deopts. What's actually different between them?
- So what's a deopt loop, and what does V8 do to protect itself from one?
- If I handed you a CPU profile, how would a deopt loop show up in it?