On Tuesday, July 7, 2015 at 8:54:29 AM UTC-4, Sunil Agrawal wrote:
>
> If my entire Node.js program is the following 
>
> setInterval(function() {}, Infinity) 
>
> 'top' shows it consumes 15-20% CPU
>
>
What is happening here is that since `Infinity` is larger than the maximum 
allowed timeout value (2147483647 -- 2^31-1), so it changes the value to 
1[1], causing the function to execute on *every* tick of the event loop.

Using a value of 100000 is still smaller than the maximum allowed timeout 
value, so in that case the function only executes every 100000 milliseconds.

[1] 
https://github.com/joyent/node/blob/d38e865fce93c00cb128034202fb1e26987efdbc/lib/timers.js#L208-L210

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/ef9682b7-ff80-49ca-bb7a-b15174774151%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to