Skip to main content
InterviewHubPRO
Section Overview
Q33

Question 33 of 50

Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

66%
Web Vitals & Performance (50 Qs)•Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

Preventing Memory Bloat in Single Page Applications (SPAs).

senior LevelSystem Design

In Simple Words: In apps running for hours without full-page reloads:

  1. Always unsubscribe from RxJS observables or remove DOM event listeners in unmount lifecycle hooks.
  2. Avoid accumulating data indefinitely in client-side caches (e.g. Apollo Client, TanStack Query); enforce maximum cache age and garbage collection limits.
  3. Use WeakMap / WeakSet for caching DOM element references so elements can be garbage collected when removed from the DOM.