EasyEnv

Memory Leak Interview: How to Test Backend Engineers on a Service That Dies Every Six Hours

November 17, 2026·8 min read·By EasyEnv
Memory Leak Interview: How to Test Backend Engineers on a Service That Dies Every Six Hours

The on-call channel gets the same message every six hours: quote-api restarted. The memory graph is a sawtooth: a straight climb, the kernel kills the process, systemd brings it back, and the line starts again from the floor. Last month someone doubled the memory limit. The sawtooth got longer. It did not go away.

Every backend team has met this service; few interviews put a candidate in front of it. This post is for engineering managers who want to watch backend candidates hunt a memory leak on a real machine: what goes on the box, how to make it fit 45 minutes, what strong and weak candidates do, and a rubric.

Why a memory leak is a good backend interview

A leak has an unusual property: the obvious fixes are wrong, and they work for a while. A scheduled restart or a bigger memory limit turns a crash every six hours into one every twelve, and leaves the bug for the next person.

That makes it a sharp test of the habit you want in a backend hire: measure, find what holds the memory, prove it, fix it, show the fix holds. It is the discipline from how to assess debugging skill with one extra demand: the evidence is not in a log line. The candidate has to produce it with a profiler or heap snapshot, and read it. "What causes memory leaks?" gets a textbook list; a box where memory is climbing right now gets their actual process.

The exercise: what is on the box

The candidate gets a shell on one Linux machine. On it:

  • quote-api, a small HTTP service that prices insurance quotes, under systemd with Restart=always and a low cgroup memory limit (MemoryMax=).
  • loadgen, a second unit sending steady synthetic quote requests, each with a unique request id in the query string, plus a config reload every few seconds.
  • The ops note, a short README: "Restarts every ~6h in prod. We raised the memory limit in October, it bought us time. Please find the cause. Do not raise MemoryMax or add a scheduled restart; we have tried both."
  • The source, readable and runnable, in the language of the role.

Three things are seeded in the code, and only one of them is the answer.

The real leak: a cache with no bound. The pricing function is memoized in a plain map keyed on the whole query string, request id included, so no key is reused and nothing is ever removed. The comment above it says // cache quotes, pricing is slow, which is true, and which is why it does not look like a bug.

The second leak, for senior roles: a listener per request. Each request subscribes a handler to a shared config emitter and never unsubscribes, and the handler keeps the request object reachable. In Node this also prints MaxListenersExceededWarning to the journal, because the default limit on listeners per event is 10 (Node.js events docs). The clue sits in journalctl for anyone who reads it.

The decoy: a big table that is not growing. At startup the service loads a large exchange rate table. In a single heap snapshot it is the biggest object by far, and it never grows. A candidate who blames the biggest thing will blame this.

The decoy is what makes the exercise discriminate. A leak is not what is large. It is what is larger than five minutes ago, and what keeps it alive.

Making it fast enough to watch

Production says six hours; the interview cannot wait that long. Tune two numbers, the load generator's request rate and MemoryMax, so memory climbs visibly on systemctl status quote-api within a couple of minutes and hits the limit in around eight to ten. The candidate then sees the sawtooth for themselves in journalctl -u quote-api and dmesg, where the kernel's OOM killer reports what it killed. Keep a slower setting in reserve, so a careful reader is not interrupted by the service dying under them.

Variants and tools by language

Seed the leak each language makes easy, and expect one tool, used twice, because a leak shows up in the difference.

  • Node.js (unbounded Map, listener never removed). Take heap snapshots from Chrome DevTools via --inspect, or with --heapsnapshot-signal or v8.writeHeapSnapshot(). The Comparison view shows what was kept, and Retainers shows what holds it (Node.js guide to heap snapshots).
  • Python (module-level dict cache). tracemalloc.start(), two snapshots a few minutes apart, compare_to() grouped by line (tracemalloc docs).
  • Go (map cache, goroutine per request never stopped). go tool pprof the /debug/pprof/heap endpoint twice and diff with -diff_base; a goroutine leak shows in /debug/pprof/goroutine (net/http/pprof docs).
  • JVM (static HashMap, connections never returned to the pool). jcmd <pid> GC.heap_dump, or -XX:+HeapDumpOnOutOfMemoryError, then the dominator tree in a heap analyser such as Eclipse MAT (Oracle troubleshooting guide).

Install the tool in advance. The interview is about using it.

What strong candidates do

In the debugging sessions we review, strong runs follow a recognisable order, whatever the tool.

  1. They confirm the problem before touching code. Memory climbing under steady load, OOM kills in the journal, sometimes the listener warning too.
  2. They separate "big" from "growing". Two snapshots, compared. The exchange rate table drops out because it has not changed. The cache map tops the difference, its entry count tracking the requests sent.
  3. They follow the retaining path to "this map holds these entries and nothing deletes them", then read the key and see the request id in it.
  4. They fix the cause and keep the behaviour. The key drops the request id and the cache gets a bound (an LRU with a size cap, or a TTL). The listener is removed when the request ends, or replaced by one subscription per process.
  5. They prove it. Load again, memory levels off for long enough that "it has not crashed yet" is not the evidence, and a last snapshot pair shows a flat difference.

Then two or three sentences for ops: what leaked, why the bigger limit only delayed it, what to watch.

What weak candidates do

  • Restart and wait, or raise the limit or add a cron restart after the brief said not to.
  • Blame the biggest object. One snapshot, the exchange rate table on top, a fix that lazy-loads it. Memory still climbs.
  • Guess from the code. They spot a cache and declare it the cause without measuring. Sometimes they are right, and nobody can tell whether they knew or got lucky.
  • Fix without verifying. A plausible change, one restart, "should be good now".

AI in the session

If the role allows AI, leave it on. EasyEnv's in-session AI panel has Chat, Agent and Plan modes with a budget ring, and every prompt and reply is kept for the review. A general question ("my service keeps running out of memory") gets a general list, and raising the limit is usually on it. A strong candidate gives the model the snapshot diff and checks its answer on the box.

A 45-minute time plan

Minutes Stage What you are watching
0 to 5 Read the brief Ops note and journal read first
5 to 12 Confirm the leak Memory measured under load, OOM kills found
12 to 28 Find the cause Two snapshots, compared, retaining path followed
28 to 38 Fix and verify Bounded cache, flat memory under load
38 to 45 Explain A note for ops, your questions

Good closing questions: "How would you have caught this before production?" and "What would you alert on?" Strong answers watch memory growth over time, not only a threshold.

Scoring rubric

Score each row 1 to 4, with one sentence of evidence pointing at a moment in the session. More on building these in how to write a technical interview rubric.

Area 1 2 3 4
Measurement Did not confirm growth Watched memory once Confirmed growth under load and found the OOM kills Plus read the journal warning and timed the growth
Evidence Guessed from code One snapshot, biggest object Compared two snapshots Compared, followed the retaining path, ruled out the decoy
Fix Raised the limit or scheduled a restart Removed the cache entirely Bounded cache, correct key Plus the listener fixed, behaviour kept
Verification None One restart Memory flat under load Flat under load, confirmed with a second snapshot pair
Explanation None Describes the change Explains the cause Explains why the earlier memory increase only delayed it, and what to monitor

A 1 in Fix is a no on its own: it is the answer ops already tried and rejected, chosen after reading the brief.

Running it on EasyEnv

On EasyEnv the exercise is a box: one Linux machine per candidate with the service, the load generator and the seeded faults, torn down after. The check behind the challenge's Run tests button can do the Verification row's work: run load, confirm memory levels off, confirm cached quotes still price correctly, confirm MemoryMax was not touched. The session is recorded, terminal and screen, so the reviewer sees the order of the hunt, which is most of what this interview measures. Each interviewer's vote stays hidden until they cast their own, so whoever watched live does not set the score for whoever watched the replay.

The box will not show how a candidate behaves on a call with the whole team while prod is down; pair it with a live incident drill for that. If your own slow death was a query rather than the heap, the database performance interview fits better.

Take the last leak your team fixed, seed it into a box, and watch two candidates hunt it. Which of them reached for the memory limit first?

For hiring teams

Hire engineers with real-world interviews

Run live coding sessions and take-home challenges in real production environments. Watch sessions back, score consistently, and hire with confidence.

Continue reading

More posts you might like

Forward Deployed Engineer (FDE) Interview: How to Hire FDEs
November 16, 2026·17 min read

Forward Deployed Engineer (FDE) Interview: How to Hire FDEs

Hiring forward deployed engineers (FDEs)? An FDE is judged inside a customer's environment, by the customer's rules. What the interview needs, the 60-minute loop we run for it, what to watch in each stage, and a rubric you can use tomorrow.

Read more
System Design Interview Tool: A Canvas Your Reviewer Can Read, Push Traffic Through and Replay
November 13, 2026·6 min read

System Design Interview Tool: A Canvas Your Reviewer Can Read, Push Traffic Through and Replay

EasyEnv now has system design questions and a System Design Lab. Candidates build the architecture layer by layer on a typed canvas, and your reviewer reads what was built, the reasoning next to it, and how it got there. Your team can push traffic through a design to find what breaks first.

Read more
Four Numbers That Tell You Whether Your Technical Hiring Works
November 12, 2026·4 min read

Four Numbers That Tell You Whether Your Technical Hiring Works

Most hiring dashboards measure activity: interviews held, candidates sourced, pipeline volume. Four other numbers actually tell you whether the process works, and three of them are uncomfortable on purpose. Here is how to measure each one without new tooling.

Read more