shifting the events object may lead to memory leak on certain smartTVs
OrenMe opened this issue · comments
The events array shifting here:
javascript-state-machine/src/jsm.js
Lines 148 to 151 in 0d60357
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.