How to fix React hydration errors
Why React hydration mismatches happen in server-rendered apps, how to read the error, and reliable fixes for dates, browser-only code, invalid HTML and extensions.
What memory leaks look like in web apps, the most common causes, how to find them with browser developer tools, and patterns that prevent them.
A memory leak happens when an application keeps references to data it no longer needs, so memory grows until the page slows down or crashes. In JavaScript, common causes are event listeners and timers that aren't removed, closures holding large objects, detached DOM nodes, unbounded caches and effects without cleanup in frameworks like React. Use browser memory tools to find what's growing and add proper cleanup.
JavaScript manages memory automatically through garbage collection, but it can only free objects nothing refers to anymore. If your code keeps references accidentally, memory keeps growing. In long-running single-page apps, dashboards and kiosk screens, leaks gradually make everything slower until the tab crashes.
Adding listeners to window, document or long-lived elements without removing them when components are destroyed keeps the components in memory.
Fix: remove listeners when no longer needed, or use AbortController signals to remove groups of listeners at once.
setInterval and repeated setTimeout calls keep running and holding references.
Fix: clear intervals and timeouts when components unmount or tasks complete.
Functions that capture large objects, such as datasets or DOM nodes, keep them alive as long as the function exists.
Fix: avoid capturing more than needed, and release references when done.
Elements removed from the page but still referenced in JavaScript, for example in arrays or maps, can't be collected.
Fix: remove references when removing elements; use WeakMap or WeakRef where appropriate.
Caches that grow forever, such as storing every API response, eventually consume too much memory.
Fix: limit cache size, expire old entries or use a least-recently-used strategy.
In React, effects that subscribe to events, sockets or timers must return a cleanup function. Similar patterns exist in Vue, Angular and other frameworks.
Fix: always clean up subscriptions in effect cleanup or component destroy hooks.
Charts, maps, editors and analytics widgets may need explicit destroy calls when removed.
Fix: read library documentation and call their teardown methods.
Chrome DevTools Memory panel offers:
Performance panel with memory recording shows whether memory returns to a baseline after garbage collection.
Effects that run differently on server and client can also cause hydration problems; see our guide to fixing React hydration errors. Pages that jump while loading have a different cause; see our guide to fixing layout shift.
Dashboards left open all day on office screens are especially prone to leaks: charts redrawn every minute, polling requests and accumulating data. Limit how much history is kept in memory, reuse chart instances rather than recreating them, and consider reloading the page automatically overnight as a safety net, while still fixing root causes.
Node.js servers can leak memory too, through growing caches, global arrays or unclosed connections. Monitor memory over time in production, use heap snapshots on staging and set alerts for unusual growth.
After fixes, repeat your test flow many times and confirm memory returns to a stable baseline. Add a simple long-running test to catch regressions.
Mobile browsers have less memory, so leaks crash tabs sooner. Include phones in long-running tests.
Our web app development team profiles and fixes memory and performance issues in complex front ends. Our web development team builds lean, fast pages, and our app development service applies the same practices to hybrid and cross-platform apps.
If memory keeps rising during normal use and doesn't drop after garbage collection, you likely have a leak.
It frees unreferenced memory, but can't free objects your code still references accidentally.
Browser developer tools, especially heap snapshots in Chrome DevTools, are the most practical starting point.
This guide is general information, not legal, tax or financial advice, and details such as prices, features and rules can change. Product and company names mentioned are trademarks of their respective owners and are used only to identify those products; UK Technology Hub is not affiliated with or endorsed by them.
Tell us about your project and get a free, fixed quote.
Get a free quoteWhy React hydration mismatches happen in server-rendered apps, how to read the error, and reliable fixes for dates, browser-only code, invalid HTML and extensions.
What causes content to jump while pages load, how Cumulative Layout Shift is measured, and practical fixes for images, ads, fonts, banners and embeds.
A calm, step-by-step guide to diagnosing and fixing a blank white WordPress page, from recovery mode and debug logs to plugins, themes and memory limits.