Skip to content

v2.2 — fix the popup-burst memory leak

Choose a tag to compare

@vakandi vakandi released this 13 Oct 14:15
· 36 commits to main since this release

Fixes the popup-burst memory leak.

Opening and closing run popups used to grow memory forever: a burst of 30
popups cost ~21 MB, and it never came back — 300 popups reached 218 MB.

Two causes, both found by eliminating one variable at a time:

  1. The popup windows were never freed. A closed, invisible, empty window that
    was never even shown still existed 30 seconds later. macOS classifies that
    memory as reachable, not leaked, so something held a live reference. We
    ruled out our data path, the update rate, the anchor panel, the drop
    animation, the autorelease pools, and every window property we set. macOS
    simply will not release these windows — so the fix is to stop creating them.
    Popped-up windows now go into a pool and get reused, capped at 12 for the
    life of the app.

  2. Every popup also built a brand-new interface tree that was left behind.
    That was the whole remaining ~19 MB per burst. The window now keeps one
    interface and swaps what it shows.

300 popups across 10 bursts: 218 MB -> 32 MB.

Because a recycled popup is the riskiest part of this change, it is asserted
rather than assumed: every stress checkpoint checks that no popup is still
showing the previous agent, and it reports zero mismatches across bursts and
30 cycles using a different agent each time.

Also corrects the stress harness itself, which was passing a zero duration that
silently made every popup cycle a no-op.