Challenge 01 — Accidental global array

Find why memory grows when you click Start leaking.

Mission

Idle — take snapshot A, then click Start leaking.

DevTools checklist

  1. Memory → Take snapshot (A)
  2. Click Start leaking — wait ~10 seconds
  3. Force GC (trash icon)
  4. Take snapshot (B) → Comparison vs A
  5. Sort by # Delta — inspect growing types

Expected signals

  • Array count and size delta grows
  • Object instances increase
  • Retainer chain leads to WindowleakStore

Hints & solution

Hint

Look for properties attached directly to the global object. The leak survives GC because the array is reachable from window.

Solution

Each interval tick pushes a large array onto window.leakStore. The global reference prevents collection.

// Fix: use module scope with bounds, or delete the reference
delete window.leakStore;

← Lesson: Global variables · All challenges