Urgent.News

What's breaking now, across thousands of outlets.

Tech

Autopsy #02: Anatomy of a Memory Leak on an 8-Hour Dashboard

Incident Report A routine PR added an auto-resizing MutationObserver to the NOC telemetry table widget so column widths adjusted when live alerts streamed in. Every 10-minute QA smoke test passed with flat memory graphs. Six hours into the Monday shift, dedicated wallboard monitors running the dispatch SPA began crashing with Chrome's Aw, Snap! ( Out of Memory ) error. T+00:00 : Initial JS heap…

On Monday, an 8-hour dashboard widget began crashing due to a memory leak caused by an auto-resizing MutationObserver. Every 10-minute QA test passed with flat memory graphs, but six hours into the shift, the dispatch SPA starting failing with a Chrome Aw, Snap! (Out of Memory) error.

Initially, developers added a cleanup function to null telemetryRows and host. However, this did not solve the problem as local testing showed a brief memory reduction after manual garbage collection. The issue persisted with the same 6-to-8 hour cycle.

The leak occurred across five runtime layers. Unremoved allocations promoted to V8 Old Space, native DOM observers acted as immortal GC roots, stale hook closures pulled entire component trees into those roots, and un-disconnected MutationObserver instances remained in unmounted routes. No unified teardown path existed due to absent AbortController wiring.

Memory allocations that survived two scavenges ended up in Old Space, where reclaiming them requires expensive Mark-Compact sweeps. A single reachable JS reference to an unmounted div class=chart-host pinned the entire detached DOM subtree in Old Space.

Stale hook closures created retainer edges from lexical environments of rendered effects, capturing 40 MB telemetryRows arrays and detached DOM containers. Native MutationObserver maintained these closures because they were registered with Blink's C++ DOM mutation agent. Without AbortController and proper teardown, early returns skipped observer.disconnect() when the host changed mid-flight, leaving partial subscriptions alive.

To fix the issue, developers should implement a single-token teardown by creating one AbortController for each useEffect that allocates DOM observers, window listeners, or network streams, and returning () = controller.abort(). They should also pair observer disconnect with { once: true } on signal to invoke observer.disconnect() atomically. Observers should only read the DOM node passed to their callback or a mutable ref, avoiding large historical state arrays from outer renders.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

ATR Stops Without Magic Numbers: Why 2.5 ATR14 Is a Convention, Not a Law

Stop = Price ± (k × ATR14) fits in one line. The problem was never the formula — it is choosing k , and knowing what the number does and does not mean.

  • 2.5 ATR14 stop loss is a convention, not a rule
  • Calibrate stop loss per instrument by examining stop-out distances
  • Static stops simplify planning size, while trailing stops reduce give-back

Autopsy #03: Why One Click Triggers 14 Re-Renders and a Layout Shift

Incident Report A design-system polish PR added a compact-density toggle to the catalog filter bar, updating --row-density on :root and equalizing row heights in useLayoutEffect .

  • Compact-density toggle introduced, aimed to improve UX
  • Performance issues on production catalog pages with 2,400 DOM nodes
  • 14 re-renders and layout shifts triggered per click

The Hidden Cost of PostgreSQL JSONB Columns Under High Write Load

A single integer increment inside a 3.4 KB PostgreSQL JSONB column generated 142 MB of Write-Ahead Log (WAL) traffic across just 20,000 updates in my local benchmark—nearly 8x more WAL than updating…

  • JSONB columns cause 8x more WAL traffic under high write loads
  • Each UPDATE creates new row version in MVCC storage
  • TOAST thresholds split JSONB into chunks in pgtoast table

More from Tuesday 17 November →