Skip to content

ComputedFn (and createTransformer) can leak memory in certain scenarios #319

@realyze

Description

@realyze

computedFn uses _isComputingDerivation() to determine whether it should cache or not. However, when getting value of a computed from within an action, _isComputingDerivation() will return true and computedFn will cache the arguments it's called with. But since we're in an action, onBecomeUnobserved will never get called to evict the arguments from the cache.

Here's the smallest reproducible scenario I can come up with: https://codesandbox.io/s/computedfn-memory-leak-5xvsg6

I think it's similar to #116 (which has been mostly—but apparently not completely—fixed by #228).

Should there be a more reliable way than _isComputingDerivation() to determine whether we're running inside an action?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions