const focusEvent = new FocusEvent('focus', {
bubbles: true
});
// Trigger the input value in the search box
const inputEvent = new InputEvent('input', {
bubbles: true
});
// Send enter
const keyEvent = new KeyboardEvent('keydown', {
code: 'Enter',
key: 'Enter',
keyCode: 13,
view: window,
bubbles: true
});
let search = document.querySelector('#side > div._1Ra05 > div > label > div > div._1awRl.copyable-text.selectable-text');
function searchList(name = "") {
try {
search.textContent = name;
search.dispatchEvent(focusEvent);
search.dispatchEvent(inputEvent);
search.dispatchEvent(keyEvent);
search.removeEventListener('focus', focusEvent);
search.removeEventListener('input', inputEvent);
search.removeEventListener('keydown', keyEvent);
} catch { console.log(error); };
}
I'm using `puppeteer` and inside
await page.evaluate(async ({
I have a loop that calls the function searchList on each `100 ms`, the problem is the browser memory usage is growing constantly, after 30min its over 1GB of ram.
I discovered that whos causing it is the `search.dispatchEvent` lines, when i comment they, the memory does not increase.
I "tried" to solve it adding:
```
search.removeEventListener('focus', focusEvent);
search.removeEventListener('input', inputEvent);
search.removeEventListener('keydown', keyEvent);
```
But it did not change anything in relation to the mem increasing over time, does someone have any idea what else i could try to stop or release the mem growing?
Obs: Copiei meu post do stackoverflow por isso está em ingles, se alguém poder ajudar agradeço.