Kong / swrv

Stale-while-revalidate data fetching for Vue

Home Page:https://docs-swrv.netlify.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

REF_CACHE retains StateRefs created for components that have been unmounted

jefrailey opened this issue · comments

Reproduction Steps

Please see my demo repository and follow the steps in the README.md.

Description

The memory used by an application that uses useSwrv() with the default time-to-live of 0 will increase as components that call useSwrv() are created. This memory is never recovered because REF_CACHE retains every StateRef created during the life of an application. The retained StateRefs are individually small, but retaining them forever causes a noticeable memory leak in long lived applications. As far as I can tell, it is not necessary to keep StateRefs after the component that consumes them is destroyed.

Closing as fixed by release 0.9.5.