Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jefrailey
Copy link
Contributor

@jefrailey jefrailey commented Dec 30, 2021

Goal

Eliminate a (slight) memory leak caused by the indefinite retention of StateRefs by the REF_CACHE when the time-to-live is 0 by removing a StateRef from the REF_CACHE when its component is unmounted (reported in #230).

How Can This Be Tested?

  1. Checkout the source branch at commit 856002c
  2. yarn
  3. yarn test
  4. Observe the test failures.
  5. Checkout the source branch at commit 2b4a1bc
  6. yarn test
  7. Verify the tests succeed.

EDIT: Corrected commit order.

This commit adds tests to assert that the `StateRef` created
by calling `useSwrv()` is removed from the data array
held in the `REF_CACHE`.

N.B. These tests fail at this commit.
Prior to this commit, the `REF_CACHE` with
the default time-to-live of `0` retained the `StateRef`s
that were added to it even after the component
that called `useSwrv()` was unmounted (destroyed).
This allowed the `REF_CACHE` to grow indefinitely
as components that called `useSwrv()` were created
and destroyed.

This commit extends the callback passed to `onUnmounted()`
that removes the `StateRef` created by the current invocation
of `useSwrv()` from the array stored in the `REF_CACHE`
at the given key.
@CLAassistant
Copy link

CLAassistant commented Dec 30, 2021

CLA assistant check
All committers have signed the CLA.

@darrenjennings
Copy link
Contributor

hey @jefrailey thanks for this patch! I've approved the build to run which is now failing. Can you fix the lint issues? Can approve afterwards. Thanks for the tests!

@jefrailey
Copy link
Contributor Author

@darrenjennings Will do. It looks like it's all formatting issues--looks like I forgot to run yarn lint. I'm busy for the rest of the evening, but will fix this first thing tomorrow.

@darrenjennings darrenjennings merged commit 7bde8fa into Kong:master Jan 4, 2022
@dcyou
Copy link

dcyou commented Jan 4, 2022

hi guys could be great also for the beta if the bug exist of course ^^ Vue3 🚀

darrenjennings pushed a commit that referenced this pull request Mar 12, 2022
Eliminate a (slight) memory leak caused by the indefinite retention of StateRefs by the REF_CACHE when the time-to-live is 0 by removing a StateRef from the REF_CACHE when its component is unmounted (reported in #230).
darrenjennings pushed a commit that referenced this pull request Mar 12, 2022
Eliminate a (slight) memory leak caused by the indefinite retention of StateRefs by the REF_CACHE when the time-to-live is 0 by removing a StateRef from the REF_CACHE when its component is unmounted (reported in #230).
adamdehaven pushed a commit that referenced this pull request Aug 25, 2022
Eliminate a (slight) memory leak caused by the indefinite retention of StateRefs by the REF_CACHE when the time-to-live is 0 by removing a StateRef from the REF_CACHE when its component is unmounted (reported in #230).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants