Why does my retry + cache logic sometimes leak memory in a long-lived SPA?

Ellen1979
Tue, 28 Apr 2026 12:14:34 +0000

Caching r.json() in an autosave loop can quietly pin a lot of memory — you’re holding the fully-parsed object graph, not some lightweight response blob. I hit this with a “small” draft payload that had nested arrays; memory crept up, GC got spiky, and the UI started feeling sticky even with a TTL because we still had multiple versions alive at once.

I’m not sure that kirupa.com link is really aimed at this exact failure mode, but the practical takeaway is the same: cache deliberately (cap entries, avoid keeping whole parsed payloads when you only need a slice, and watch out for “latest + a few retries” accidentally becoming “latest + N copies”).