I have a simple main / worker messaging demo that consumes memory continuously. The below sample will consume > 1GB after 10 minutes.
OS: Windows 10
Env: VMWare VM with 4 virtual procs and 32 GB RAM
Deno 1.1.0
to run: deno run --allow-read parent.js
parent.js
let worker = new Worker(new URL("worker.js", import.meta.url).href, { type: "module" });
let struct = {
headers: ["database", 1, 2],
value: 1
};
worker.postMessage(struct);
worker.onmessage = async (e) => {
let { got, hit } = e.data;
if (hit) console.log("hit: " + got);
struct.value = got + 1;
worker.postMessage(struct);
};
worker.js
let expected = 12345;
let struct = {
got: null,
hit: null,
};
self.onmessage = async (e) => {
const { value } = e.data;
if (value % 10000 === 0) console.log(value);
struct.got = value;
struct.hit = value === expected;
postMessage(struct);
};
I performed more tests to see if the bug is OS specific or is a regression bug. The following environments all exhibit the same issue:
OS: Windows 10
Env: Intel i7-8550U laptop with 16GB RAM
Deno 1.1.0
OS: Ubuntu 19.10
Env: Intel Atom x5-Z8350 laptop with 4GB RAM
Deno 1.1.0
OS: Windows 10
Env: Intel i7-8550U laptop with 16GB RAM
Deno 1.0.2
I'm also able to replicate this on macOS, I think it might be related to this issue. But fortunately the memory will be freed once the worker is terminated via invoking worker.terminate().
Most helpful comment
I'm also able to replicate this on macOS, I think it might be related to this issue. But fortunately the memory will be freed once the worker is terminated via invoking
worker.terminate().