Re: [nodejs] EMFILE on process.memoryUsage()

311 views
Skip to first unread message

Ben Noordhuis

unread,
Oct 11, 2012, 6:24:07 AM10/11/12
to nod...@googlegroups.com
On Thu, Oct 11, 2012 at 3:13 AM, Daniel Friedman <dan...@ninjablocks.com> wrote:
> Hey guys,
>
> I'm getting Error: EMFILE, too many open files on calling
> process.memoryUsage().
>
> I see there was an issue that was fixed in v0.6.14, however I'm on v0.8.8
> and still seeing it.
>
> There is a test for the bug in test/simple/test-memory-usage-emfile.js which
> opens up 255 files and then tries to call process.memoryUsage() which seems
> to pass. However, when I bump the number of files to say 1024 it fails.
> Excerpt from the test:
>
>> while (files.length < 256)
>> files.push(fs.openSync(__filename, 'r'));
>> var r = process.memoryUsage();
>
>
> I was wondering what the significance of the 256 is? Unless I'm missing
> something, or doing something wrong, it seems like there might still be an
> issue.
>
> Side note, winston (logging library) uses this call when trying to handle
> exceptions, causing it to fail and node to exit. So I'd be careful if you're
> relying on that feature of the library.
>
> Dan

You didn't mention your operating system but if it's OS X, you need to
completely log out and log in again for the ulimit change to become
effective.

The number 256 is not significant except in a programmer aesthetic sense.

Fadrizul H

unread,
Oct 11, 2012, 9:21:21 AM10/11/12
to Daniel Friedman, nod...@googlegroups.com
Increase yer ulimit

Sent from my Windows Phone

From: Daniel Friedman
Sent: 11/10/2012 6:17 PM
To: nod...@googlegroups.com
Subject: [nodejs] EMFILE on process.memoryUsage()

Hey guys,

I'm getting Error: EMFILE, too many open files on calling process.memoryUsage(). 

I see there was an issue that was fixed in v0.6.14, however I'm on v0.8.8 and still seeing it.

There is a test for the bug in test/simple/test-memory-usage-emfile.js which opens up 255 files and then tries to call process.memoryUsage() which seems to pass. However, when I bump the number of files to say 1024 it fails. Excerpt from the test:

while (files.length < 256)
  files.push(fs.openSync(__filename, 'r'));
var r = process.memoryUsage();

I was wondering what the significance of the 256 is? Unless I'm missing something, or doing something wrong, it seems like there might still be an issue.

Side note, winston (logging library) uses this call when trying to handle exceptions, causing it to fail and node to exit. So I'd be careful if you're relying on that feature of the library.

Dan

--
Job Board: http://jobs.nodejs.org/
Posting guidelines: 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 post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Daniel Friedman

unread,
Oct 11, 2012, 8:27:33 PM10/11/12
to nod...@googlegroups.com, Daniel Friedman
Seeing it on AWS's Linux Image, ulimit -n is 1024. I get the feeling something must not be cleaning up after itself if there are 1024 open files after a given period of time. I'll bump up the limit in the mean time.

Cheers,
Dan
Reply all
Reply to author
Forward
0 new messages