-
Notifications
You must be signed in to change notification settings - Fork 284
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
Allocation failure scavenge might not succeed #2388
Comments
You get a crash because
That is expected. When you spawn two processes, one prints odd and the other prints even numbers. Their stdouts interleave and you see that in the log. When one process dies (due to out-of-memory error), it prints the error to its stderr stream. However, it may be delayed several millisecond and in the meantime the other process keeps printing to its stdout, so you see odd numbers between these two events.
As explained, require('fs').writeSync(process.stdout.fd, val + ' ' + index + '\n'); |
I would disagree here – one, this doesn’t properly work on Windows, and two, it’s better to write code so that it handles backpressure correctly. Additionally, this problem should be far less impactful from Node.js v13.3.0 upwards. |
I'm not really sure what you mean by this... It works fine on all machines I tested, from windows 7 to windows 10 with all versions of Node.js from v8.x to the current master.
Sure, in a production code I would suggest using either an async function, or callbacks on |
Would changing it to the following work (since making it async won't act in a blocking way and allow things to be deallocated)? function loop() {
const val = wallet.getPublicKey(index);
const bLetter = val[1];
if (val.startsWith(`G${bLetter}ABCDE`)) { // Changed ABCDE from something else
done = true;
console.log(val, index);
}
console.log(index);
if (index >= 2147483647) {
console.log("Ran out.");
return;
}
index += runTimes;
if (!done) {
setImmediate(loop)
}
} |
Yes, that should work fine. If you still experience crash with the new code, you probably have some other memory leak in your application or in dependencies. Note that after PR nodejs/node#30710 (released in v13.3.0), even with the sync usage of |
|
One approach that would be “correct” in a sense would be to use |
closing as answered, pls reopen if there is anything outstanding. |
I'm getting a crash on Node.js. It took a while to get to this crash, and the error is not very descriptive about what is going on here.
What I also find weird, is below in the logs, towards the end it was only printing odd indexes.
20100688
was the last even number that was printed in the indexes. So I'm not sure if one of those child processes failed or what happened. It didn't actually run the.on("close"
method until the very end tho, which is weird.Any ideas of what is going on here?
Command Ran
index.js
process.js
Latest Logs
...
The text was updated successfully, but these errors were encountered: