ds300 / ds300/derivablejs

Freeing memory once a derivation is no longer needed

Open
#36 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
518
Forks
23
PR merge metrics
No merged PRs in 30d

Description

Consider this code:

```
a = atom(5)
d = derivation(() => a.get() + 1)
d.get()
```

A side effect of `d.get()` is setting `a._children[0]` to point to `d`.

When I'm done with `d`, how do I get rid of that pointer?

Right now I use derivations in my React components which call `.get()` on derivables outside of the component. When the component is unmounted, the pointers like `a._children[0]` above are causing a major memory leak, because the entire component is sticking around as the closure-context to the un-garbage-collectable derivation.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.