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

Memory leak in stopListening? #3453

Closed
albinohrn opened this issue Jan 22, 2015 · 1 comment · Fixed by #3455
Closed

Memory leak in stopListening? #3453

albinohrn opened this issue Jan 22, 2015 · 1 comment · Fixed by #3455

Comments

@albinohrn
Copy link

Hi,

this issue is some what related to ticket #3226 but it's not the same. If you think they are feel free to close and reference that.

After the fix of #3226 there's still a leak. But this doesn't just apply to the listenToOnce. Take a look at the following example. (The example runs Backbone v1.1.2 but the master works the same way).

The problem is that if the model I'm listening to has a listener as well. Then the view.listeningTo will not be cleaned up correctly.

It is because of this line:

    if (remove || _.isEmpty(obj._events)) delete this._listeningTo[id];

obj._events isn't empty and therefore the view will keep its reference to the model. Is this correct? In our project this causes problems since the object that is listened to will always have its own listeners and where using listenToOnce so the references to the old objects will be kept "forever". But we might have to rethink our solution to workaround this issue?

/Albin

@melnikov-s
Copy link
Contributor

A pull request #3049 is already open to address this issue. Although there seems to be no desire to merge it at this time.

jridgewell added a commit to jridgewell/backbone that referenced this issue Jan 22, 2015
jridgewell added a commit to jridgewell/backbone that referenced this issue Jan 22, 2015
jridgewell added a commit to jridgewell/backbone that referenced this issue Jan 23, 2015
jridgewell added a commit to jridgewell/backbone that referenced this issue Jan 25, 2015
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

Successfully merging a pull request may close this issue.

2 participants