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

shifting the events object may lead to memory leak on certain smartTVs #178

Open
OrenMe opened this issue Apr 30, 2019 · 0 comments
Open

Comments

@OrenMe
Copy link

OrenMe commented Apr 30, 2019

The events array shifting here:

if (observers.length === 0) {
events.shift();
return this.observeEvents(events, args, event, previousResult);
}

can result in memory allocation leak in some smartTVs(I won't specify the make and model, as it seems like a nasty security bug, which I opened an issue already on).
As the array shift method preforms the operation on the array object itself then it may lead to memory allocation problems in certain circumstances.
Is there a reason to favour Array.shift over doing const restEvents = events.slice(1); ?
The slice operation creates a new array object and I can only assume that it is not affected from the same implementation bug in the JS engine on the aforementioned smartTVs.
This also avoids passing the events object by ref which might also be good idea to avoid the referencing between calls, although I know nothing touches it at the moment so there's no real issue.

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

1 participant