Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ObserverCallbacks continues growing with dead callback #18

Open
naqtn opened this issue Feb 23, 2015 · 3 comments
Open

ObserverCallbacks continues growing with dead callback #18

naqtn opened this issue Feb 23, 2015 · 3 comments

Comments

@naqtn
Copy link

naqtn commented Feb 23, 2015

Object.observe() appends the callback to [[ObserverCallbacks]] .
On the other hand, Object.unobserve() does not care about [[ObserverCallbacks]] .
Then [[ObserverCallbacks]] continues growing big with unused callback while the system runs.

I implemented current specification straight forward, then I encountered this problem.

I think Object.unobserve() should remove it.
Or, somewhere in delivering steps (the end of AllChangeRecords ?) might be better point.
because records in [[PendingChangeRecords]] could remain if Object.unobserve() immediately removes.

@arv
Copy link
Owner

arv commented Feb 23, 2015

The spec only describes semantics. Things like GC is unobservable. An implementation needs to make sure that it cleans up unreachable objects.

It is possible that we need to make something clearer in the spec here?

@arv
Copy link
Owner

arv commented Feb 23, 2015

The spec uses the term "List" which is an implementation specific data structure.

@naqtn
Copy link
Author

naqtn commented Feb 23, 2015

(I posted a comment but it was unclear. I rewrite.)

I've thought even if internal property is not directly accessible via ECMAScript code, but acts like usual ECMAScript Object (especially reachability manner in this case).
The event queue holds [[ObserverCallbacks]], and [[ObserverCallbacks]] holds "unused callback", and I think "unused callback" is reachable after Object.unobserve().

Is it incorrect?

If I misunderstand, who holds strong referrence?
After Object.observe() called, the callback can be refered only from two paths.
(User main program can release it. right?)

  1. user main program => observable => [[Notifier]] => [[ChangeObservers]] => record =([[Callback]])=> callback
  2. event queue => [[ObserverCallbacks]] => callback

If [[ObserverCallbacks]] behaves like weak referrence, how about first internal properties?
And strictly when the callback becomes garbage Object.unobserve() after called?

P.S.

"List" which is an implementation specific data

Well.., I'll read the spec again carefully.

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

No branches or pull requests

2 participants