Skip to content
Performance & Accessibility

A Practical Guide to Memory Leaks in Long-Lived Pages

Memory that a page keeps allocating and never releases, a problem for dashboards and apps left open for hours.

MediaScaleUp Editorial Team 2 min read 16 views
A Practical Guide to Memory Leaks in Long-Lived Pages

The key figures

Detached nodes
removed DOM elements still referenced in JavaScript
Listeners
event listeners that are never removed
Timers
intervals that keep running after components unmount
Heap snapshots
browser tools compare memory over time

Why this is worth getting right

Leaks make tabs slow and eventually crash them, and the symptoms appear long after the code that caused them ran.

Do this, not that

Do

  • Remove listeners and timers when components unmount
  • Take heap snapshots during long sessions
  • Watch memory during automated tests
  • Avoid global caches that grow without limits
  • Test pages left open for hours

Don’t

  • Growing arrays that are never cleared
  • Closures holding large objects
  • Ignoring slow degradation reports
  • Testing only fresh page loads

When to bring in help

Our advice Bring in help when long sessions slow down or crash.

Where this comes from

The figures and practices above come from the sources listed.

Working on something like this?

We take on Performance & Accessibility work for teams who want it done once, properly. Tell us what you are building and we will tell you honestly whether we are the right studio for it. Start a project.

Where to go next

Spotted something wrong? Report an error on this page. We correct on the page and say what changed.

All services

The work behind this article, and what it costs.

MediaScaleUp Editorial Team

Articles here are researched, written and checked by the MediaScaleUp studio team before they are published, and dated when they are reviewed.

Keep reading

More in Performance & Accessibility