Giter Club home page Giter Club logo

Comments (5)

Riim avatar Riim commented on July 19, 2024

Привет!

Ссылки на реакции вычищаются для того чтобы сборщик мусора мог находить неиспользуемые ячейки и они не зависали в памяти. Обратные ссылки на зависимости этому никак не мешают, скорей всего можно и их чистить, но смысла усложнять здесь скорей всего нет.

from cellx.

gonzobard777 avatar gonzobard777 commented on July 19, 2024

Пример:

const a = new Cell(()=>b.get());
const b = new Cell(7);

const noop = ()=>{};
a.onChange(noop);
a.offChange(noop);
  1. b не ссылается на a
  2. но a так и ссылается на b

какую из ячеек gc посчитает неиспользуемой и удалить из памяти?

from cellx.

gonzobard777 avatar gonzobard777 commented on July 19, 2024

походу понял, надо просто разомкнуть ссылку друг на друга, и тут по-идее не важно что чистим, могли почистить зависимости вместо реакций

from cellx.

Riim avatar Riim commented on July 19, 2024

тут по-идее не важно что чистим

Всё же это важно)) В примере выше на a никто не ссылается, это и даёт GC возможность удалить его. То что сам a при это на кого-то ссылается ему (GC) пофик. Другими словами удаляется то, что не используется, если после удаления a GC увидит, что b тоже никому уже не нужен, то и его почистит.

from cellx.

dwfe avatar dwfe commented on July 19, 2024

ага, понял, благодарю

from cellx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.