You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 1, 2025. It is now read-only.
Creating an atom with a selector to lazily initialize the default value like mentioned in the documentation here will cause all values set to it to leak.
Disabling cache for the selector created by atomWithFallback fixes the problem and should not cause any issue as I don't see why we would want to keep old values for this selector. It is also very cheap to execute.
const sel = Recoil_selector({
key: `${options.key}__withFallback`,
+ cachePolicy_UNSTABLE: { eviction: 'most-recent' },
get: ({
get
}) => {
If this makes sense I can open a PR to make this change.
Summary:
- Wrapping selector does not need to cache because the selector being wrapped has caching options
- Related to facebookexperimental#1840
Reviewed By: drarmstr
Differential Revision: D36956571
fbshipit-source-id: 2709b8603f94158f6a7843e743d1311ff569685d
Summary:
Pull Request resolved: #1844
- Wrapping selector does not need to cache because the selector being wrapped has caching options
- Related to #1840
Reviewed By: drarmstr
Differential Revision: D36956571
fbshipit-source-id: 1c5729e96ffdbcf94c3afdd8ce42648d4148e1b6
Summary:
Pull Request resolved: facebookexperimental/Recoil#1844
- Wrapping selector does not need to cache because the selector being wrapped has caching options
- Related to facebookexperimental/Recoil#1840
Reviewed By: drarmstr
Differential Revision: D36956571
fbshipit-source-id: 1c5729e96ffdbcf94c3afdd8ce42648d4148e1b6
eagle2722
added a commit
to eagle2722/Recoil
that referenced
this issue
Sep 21, 2024
Summary:
Pull Request resolved: facebookexperimental/Recoil#1844
- Wrapping selector does not need to cache because the selector being wrapped has caching options
- Related to facebookexperimental/Recoil#1840
Reviewed By: drarmstr
Differential Revision: D36956571
fbshipit-source-id: 1c5729e96ffdbcf94c3afdd8ce42648d4148e1b6
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Discussed in #1821
Originally posted by janicduplessis May 24, 2022
Issue
Creating an atom with a selector to lazily initialize the default value like mentioned in the documentation here will cause all values set to it to leak.
This will leak:
This is fine:
The issue is caused by the selector created by atomWithFallback (https://github.com/facebookexperimental/Recoil/blob/main/packages/recoil/recoil_values/Recoil_atom.js#L661) which will cause all set on the atom to be cached.
Suggestion
Disabling cache for the selector created by
atomWithFallback
fixes the problem and should not cause any issue as I don't see why we would want to keep old values for this selector. It is also very cheap to execute.const sel = Recoil_selector({ key: `${options.key}__withFallback`, + cachePolicy_UNSTABLE: { eviction: 'most-recent' }, get: ({ get }) => {
If this makes sense I can open a PR to make this change.
Repro
https://codesandbox.io/s/clever-wilbur-8cv6qr?file=/src/App.js
Open chrome devtools and go to the Memory tab. Notice ever increasing memory usage for the .csb.app js context.
By taking a snapshot we can clearly see the leaked Transaction objects.
Set
LEAK
to false and refreshObserve no more memory leak
The text was updated successfully, but these errors were encountered: