Skip to content

Event listeners added to window removed on destroy - #1123

Open
johnkeisuke wants to merge 1 commit into
tabalinas:masterfrom
johnkeisuke:master
Open

Event listeners added to window removed on destroy#1123
johnkeisuke wants to merge 1 commit into
tabalinas:masterfrom
johnkeisuke:master

Conversation

@johnkeisuke

@johnkeisuke johnkeisuke commented May 24, 2018

Copy link
Copy Markdown

Fixes #1122

I added a unique ID to each table created to be able to detach its listeners easily. The IDs are recycable in order to not increment endlessly the value last ID.

@barry8schneider

Copy link
Copy Markdown

What is the use case for this change?

@johnkeisuke

Copy link
Copy Markdown
Author

Using ajax to load data from server.

In my case I was managing groups of users, displayed in tables. These groups could be deleted or created several times throughout the day and the event listeners were being accumulated. It is a small memory leak, but it is.

@srivanov

Copy link
Copy Markdown

Merge this because it's a memory leak fix.

rok9ru added a commit to rok9ru/jsxgrid that referenced this pull request Aug 28, 2026
.off("resize", this._refreshSize) never matched what .on() bound via
$.proxy(), so every destroyed grid left a dangling window resize listener
forever. Namespaces the listeners per-grid-instance so detach actually works,
and adds the previously-missing detach for the load listener too.

Cherry-picked from upstream PR tabalinas#1123.
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 this pull request may close these issues.

Memory leak due to window event listeners not being removed

3 participants