-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Idiomatic Streams usage with Promises causes memory leaks #5391
Comments
Streams are supposed to be either sync or async depending on which you prefer. Also, in theory the |
Also: BattleStreams are designed to be sync. |
So this should be closed as WAI? And users should just use |
Well, if it leads to a memory leak under normal usage, clearly something needs to be fixed. We should just figure out why. |
It's unclear to me why using a sync stream would cause a memory leak. Do you have details? |
Not really. await x();
y(); is mostly equivalent to x(() => process.nextTick(y)); But ofc, |
When running this excerpt from #5370 while ((format = this.getNextFormat())) {
const seed = this.prng.seed;
lastFormat = format;
await new Runner(Object.assign({format}, this.options)).run().catch(err => {
failures++;
console.error(
`Run \`node dev-tools/harness 1 --format=${format} --seed=${seed.join()}\` ` +
`to debug (optionally with \`--output\` and/or \`--input\` for more info):\n`, err);
});
} The heap accumulates Now!!! Last night I was speculating that this may be an engine regression, since V8 has put some work in optimizing promise ticks in recent versions.... And... That's indeed the case ! https://gist.github.com/Slayer95/6456a5d29ca17935d62d301f4a76d389 Test case leaks in Node v10.15.3, but it doesn't in v8.15.1 ! PS. Reproduced in |
Looks like you should report a V8 bug, and I should file this away as "not my fault". ;) Feel free to work around with the |
Narrowed down to this code. Only the However, I think the harness code isn't using async function runGame(logOutput) {
let chunk;
while ((chunk = await MY_STREAM.read()))) {
if (logOutput) console.log(chunk);
}
} |
From #5370 (comment)
The text was updated successfully, but these errors were encountered: