Phát hiện: Chrome DevTools > Memory tab, check heap snapshots.
Nguyên nhân:
- Quên cleanup subscriptions/timers trong useEffect.
- Event listeners không remove.
- Abort controller không cancel fetch
Fix: return cleanup function trong useEffect.
Pattern: const controller = new AbortController(); return () => controller.abort();
Detection: Chrome DevTools > Memory tab, compare heap snapshots.
Common causes:
- Forgetting to clean up subscriptions/timers in useEffect.
- Event listeners not removed.
- Fetch not cancelled via AbortController
Fix: return a cleanup function from useEffect.
Pattern: const controller = new AbortController(); return () => controller.abort();