Frontend Developer Interview Question

Users report the app gets slower the longer they leave it open. How would you track that down?

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

Quick answer

That pattern points to a leak or unbounded growth. Take heap snapshots in DevTools at two points after the same user flow, compare retained sizes and look at what is holding the detached DOM nodes. The usual causes are listeners and subscriptions that are never removed, timers that keep running after unmount, caches that never evict, and closures capturing large objects. Fix by tearing down everything a component created.

Why interviewers ask this

The interviewer wants a methodical debugger, not a guesser. Memory issues cannot be fixed by reading code alone, so they are checking whether you know the tooling: heap snapshots, allocation timelines, detached nodes and the performance monitor. It also probes lifecycle discipline, since most leaks in single page apps come from something set up on mount with no matching cleanup.

How to structure your answer

  • Confirm the symptom with a memory measurement, not a hunch.
  • Describe the three snapshot comparison over a repeated flow.
  • Name the usual suspects you check in code.
  • Explain the fix pattern: every subscription gets a teardown.

Example answer

Spoken example, first person

I would first confirm it is memory and not something else, so I would leave the performance monitor open and repeat the flow the users describe, watching the heap and the listener and node counts. If they climb and never come back down after a forced collection, it is a leak. Then I take a heap snapshot, run the flow ten times, take another, and compare by retained size. Detached DOM nodes are the giveaway, and the retainer path tells me what is holding them. In practice it is almost always something set up without a matching teardown: a resize or scroll listener on window, a socket subscription, an interval, or an observer that outlives the component. I found one where a chart library attached a listener per render and only removed one on unmount, so the count grew with every navigation. The fix pattern is boring but effective: anything created in an effect returns its cleanup, and any cache gets a size limit rather than growing forever.

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

  • What is a detached DOM node and how do you find what retains it?
  • How would you prevent this class of bug in code review?
  • How do you tell a leak apart from a cache that is simply large?

Related frontend 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