-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
Closed
Labels
help wantedIssues that need assistance from volunteers or PRs that need help to proceed.Issues that need assistance from volunteers or PRs that need help to proceed.memoryIssues and PRs related to the memory management or memory footprint.Issues and PRs related to the memory management or memory footprint.processIssues and PRs related to the process subsystem.Issues and PRs related to the process subsystem.
Description
Sorry if it is a dumb question/issue, but why does this code:
for (i = 0; i < 1000000; i++) {
console.log('abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc' + i);
}
hang node
for a few seconds (at around i = 1500) before resuming again? During the hang the amount of memory used by the node
process increases very fast and the CPU usage is very high during that time.
On the other hand, if I write:
for (i = 0; i < 1000000; i++) {
console.log(i);
}
then the node
process does not hang at all.
The reason I am asking is that I have a piece of code which involves printing inside a loop, and it also hangs, but for much longer (like 30-60 seconds, before resuming again). The code prints the paths of all files in a directory (walking recursively): https://gist.github.com/pgkos/f0a650daf56aa49899e9.
The issue occurs on both io.js v2.0.2 and node.js v0.12.2, on Ubuntu 64-bit.
Metadata
Metadata
Assignees
Labels
help wantedIssues that need assistance from volunteers or PRs that need help to proceed.Issues that need assistance from volunteers or PRs that need help to proceed.memoryIssues and PRs related to the memory management or memory footprint.Issues and PRs related to the memory management or memory footprint.processIssues and PRs related to the process subsystem.Issues and PRs related to the process subsystem.