Skip to the page

Production and testing · senior

Finding slow screens: change detection, memory and big lists

Measure first. Typical causes are endless change detection, leaked subscriptions and rendering thousands of rows.

The notes

What you must know

  • Tools: Angular DevTools profiler (cycles, time per component, what triggered each) and the Chrome Performance panel.
  • With Zone.js a third-party chart running requestAnimationFrame or timers inside the Angular zone triggers a check on every tick. Run it outside the zone.
  • Memory leak: open and close the dialog 10 to 20 times, force garbage collection, compare heap snapshots. Growing component counts and detached DOM nodes show a leak.
  • Common holders of leaked instances: a subscription to a root service Subject, a timer, a listener on window.
  • A 5,000-row table: render only visible rows (virtual scroll) or paginate.
  • Avoid track by object when the list is re-fetched, method calls in each row, and filtering on every keystroke without debounce.
  • Use OnPush or signals so a row updates alone.

The red pen

Common traps: mistake → fix

  • Mistake: More hardware fixes slow screens

    Fix: measure and remove the cause.

  • Mistake: Destroying a component frees all memory

    Fix: a root service can still hold it.

Easy to hard

Questions interviewers ask, easy to hard

  1. A screen lags all the time. How do you investigate?
  2. Memory grows every time a dialog opens. What do you do?
  3. A 5,000-row table freezes. What are your options?
  4. How do you prove a leak?

Practise

Practise with these questions

Explain it out loud

Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.

Practise by voice

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview