I'm using a webworker to pass some data at an interval of 10 ms. In the task manager I can see the working memory set increasing till I don't cancel the interval.
Here's what I'm doing:
Sending:
function send() {
setInterval(function() {
const data = {
array1: get100Arrays(),
array2: get500Arrays()
};
let json = JSON.stringify( data );
let arbfr = str2ab (json);
worker.postMessage(arbfr, [arbfr]);
}, 10);
}
function str2ab(str) {
var buf = new ArrayBuffer(str.length*2); // 2 bytes for each char
var bufView = new Uint16Array(buf);
for (var i=0, strLen=str.length; i<strLen; i++) {
bufView[i] = str.charCodeAt(i);
}
return buf;
}
I also tried to do only this, but with no success:
// let json = JSON.stringify( data );
// let arbfr = str2ab(json);
worker.postMessage(data);
Anyone know why this might be leaking? I'm currently trying this on Chrome.