-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Exception removing event listener #905
Comments
I think the documentation is not up to date with this one (or the code isnt - it depends^^). |
Great, thanks very much |
I just tried this but it seems that a reference to the object is still held in memory after 'removing' the listener. I'm reasonably sure the listener is the issue as the rectangle object disappears from memory if I don't add a listener to it. Any suggestions? |
Am I right in thinking that went in to 2.6.5? I'm currently running 2.6.3. |
It's time to upgrade then :D. You can take a look into the changelog file and double check which version it is was added and what changed overall. It should not cause any issues to update a minor version |
I've updated to version 2.6.6 and it seems the issue remains. Below is the code I've been testing with:
I've taken memory dumps in the following scenarios:
In Scenario 1, 23 circle elements exist and none are detached. I'm not sure what the extra 3 are but it seems consistent amongst scenarios so I've ignore these. This is the behaviour I expect. In Scenario 2, 3 circle elements exist and none are detached. This is the behaviour I expect. In Scenario 3, 3 circle elements exist and 20 are detached (but still reachable from the window). I would have expected 3 to exist and none to be detached (as in scenario 2 where listeners hadn't been created). |
What do you mean with:
|
That's the description the dev tools in Google Chrome gives. Detached means that it's no longer in the dom, and since it still appears in the memory dump I assume 'but still reachable from the window' means that it's still held in memory for the window. |
can it also give you the path from where it is reachable? That would help a lot! |
It does - when you take the memory dump, select one of the detached circle instances and it lists the retainers at the bottom. I tried to fathom it out but it didn't make sense to me.
|
Thank you! |
Just having a look at it again. In the |
oooohh right! We fixed this in the 3.0 and forgot to backport it! So yes you are completely right. There is a memory leak. Take a look into the 3.0 branch in the event.js file were you can see what was changed to fix this issue. I am currently working to get 3.0 out as soon as possible so I am short on time. Do you think you can create a PR for this? |
I'm sorry but from looking at the master vs 3.0.0 branch I don't understand what changes need to be made. No worries about getting it fixed in 2.x, I can wait until 3.0 is out. |
### Fixed - fixed calling `parent()` on `documentFragment`s children (#927) - parser is not focusable anymore (#908) - `SVG.Element.click(null)` correctly unbinds the event (#878) - fix memory leak (#905) ### Added - `SVG.Set` now accepts another Set as input (#893) - `on()/off()` accepts multiple event names as input (backport from 3.0)
I backported the fix so that shouldnt be an issue anymore. See 2.7.0 |
I think I've followed the documentation when trying to remove a click event listener (http://svgjs.com/events/#element-click) however it results in an exception (I'm using 2.6.3):
Code is as follows:
It might be worth noting that the error also occurs when removing the listener in the more likely case where a click listener has previously been set:
The text was updated successfully, but these errors were encountered: