Backend Developer Interview Question

A service gets killed for running out of memory every couple of days. How do you investigate?

What the interviewer is probing, how to structure your answer, and a spoken example you can adapt.

Quick answer

Confirm the pattern first from metrics: steady growth points to a leak or unbounded cache, while a sharp spike points to a single request loading too much at once. Capture a heap profile before and after a growth period and compare retained allocations. The usual causes are caches without eviction, growing collections held by long lived objects, unclosed resources, and endpoints that load an entire result set into memory.

Why interviewers ask this

The interviewer wants a method rather than a guess, plus evidence you have used a profiler in anger. Distinguishing gradual growth from spikes is the key diagnostic split, and it changes where you look. They are also checking whether you would reach for restarts and a bigger memory limit as a permanent answer, which hides the problem until traffic doubles.

How to structure your answer

  • Separate steady growth from spiky allocation using the metrics.
  • Capture and compare heap profiles across a growth window.
  • Enumerate the usual causes and check the recent changes.
  • Put a guardrail in place so it cannot recur silently.

Example answer

Spoken example, first person

The shape of the graph tells me where to look. A slow climb across days that survives quiet periods is a leak or a cache with no bound. A sawtooth that spikes on particular requests means something loads too much at once. For the first case I take heap profiles a few hours apart under similar traffic and diff them by retained size, then look at what holds the biggest objects. In practice it has usually been something boring: a map used as a cache with no eviction and no maximum, a metrics label built from a user supplied value so the cardinality grew forever, or listeners registered on a long lived object and never removed. For spikes I look for endpoints that read a whole table into a list rather than streaming, or a batch job that loads every row before writing. I hit exactly that with a CSV export that materialized a million rows; streaming it in pages made the memory flat. Afterwards I add an alert on the memory trend rather than only on the crash, so I hear about it before the restart does.

Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.

See how it works

Follow-up questions to expect

  • How would you decide whether it is a leak or just a large working set?
  • What would you cap to stop an unbounded cache growing again?
  • How do garbage collector settings change what you see here?

Related backend developer questions

Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.

Predict my questions

Rehearse the hard questions before they are asked

Practise with a live copilot, then walk in ready. A $29 Session Pass gets you through the interview with no subscription and no lock-in.

Get GhostPilot