Re: Should node.js be using this much memory?

7,093 views
Skip to first unread message

mscdex

unread,
Jul 17, 2012, 9:18:32 PM7/17/12
to nod...@googlegroups.com
On Tuesday, July 17, 2012 8:46:35 PM UTC-4, Carlos wrote:
I have three node.js express webapps served via vhost under a single node.js process which is itself behind a lighttpd proxy.  The only modules used by the three apps are connect, express, express-messages, jade, nodemailer and node-sqlite3.  That's it.  (The node apps are not using mongo or mysql.)  As you can see, the VM for node is approaching a gigabyte. Wow.  I might add that the web apps are just sitting there, not getting any hits.  For comparison, I see that the node REPL pulls 621MB of vm on this system.

I wouldn't worry about the VM size. The memory actually being used (RES) by node is only 22mb here. 

wavded

unread,
Jul 17, 2012, 9:35:53 PM7/17/12
to nod...@googlegroups.com
mscdex, question about that, I have a process running at 370 some MB in RES (in TOP) but the output from process.memoryUsage() is 51 MB.  Any clues on that?  I know Linux memory management is weird but I have been relying on process.memoryUsage().  What is it actually?

Ben Noordhuis

unread,
Jul 17, 2012, 9:52:03 PM7/17/12
to nod...@googlegroups.com
On Wed, Jul 18, 2012 at 3:35 AM, wavded <wav...@gmail.com> wrote:
> mscdex, question about that, I have a process running at 370 some MB in RES
> (in TOP) but the output from process.memoryUsage() is 51 MB. Any clues on
> that? I know Linux memory management is weird but I have been relying on
> process.memoryUsage(). What is it actually?

$ node -pe 'process.memoryUsage()'
{ rss: 6701056, heapTotal: 3018752, heapUsed: 1587360 }

rss is what node thinks the RSS is (may not quite match what external
tools report - it's complicated).

heapTotal and heapUsed relate to the V8 heap, not the global heap.

wavded

unread,
Jul 17, 2012, 10:01:00 PM7/17/12
to nod...@googlegroups.com
Thanks for clarification Ben.  That makes sense and the 51 MB I was referring to was the heapUsed value which was just one part of the picture as I just learned.  What typically takes up the most memory outside of the V8 heap?  Open file descriptors? (in this particular app I'm making a lot of HTTP requests).  Anyway to tap into that information?

Ben Noordhuis

unread,
Jul 18, 2012, 7:22:55 AM7/18/12
to nod...@googlegroups.com
On Wed, Jul 18, 2012 at 4:01 AM, wavded <wav...@gmail.com> wrote:
> Thanks for clarification Ben. That makes sense and the 51 MB I was
> referring to was the heapUsed value which was just one part of the picture
> as I just learned. What typically takes up the most memory outside of the
> V8 heap? Open file descriptors? (in this particular app I'm making a lot of
> HTTP requests).

It's probably buffers. A 10 MB buffer object, for example, uses a
couple of bytes of V8 heap space and 10 MB of global heap space.

> Anyway to tap into that information?

node-inspector or node-webkit-agent? I'm not sure if they deal with
buffers properly, though.

dvbportal

unread,
Jul 18, 2012, 1:21:19 PM7/18/12
to nod...@googlegroups.com
To answer to the question: certainly not!

Node.js 0.8 with its current memory usage is a big problem for hosting providers. Several MBs increased memory usage multiplies to many additional Gigs and someone has to pay for that.

Is clear what change in v0.8 is responsible for the increased memory usage?
Is it possible to build a custom version with old components?
Are there command line options to control the memory use?

Vyacheslav Egorov

unread,
Jul 18, 2012, 1:37:47 PM7/18/12
to nod...@googlegroups.com
Is there a big difference between heapUsed and heapTotal on your app?

If you seem big difference try rolling nodejs build forward to V8 3.11.10.13.

--
Vyacheslav Egorov


On Wed, Jul 18, 2012 at 4:01 AM, wavded <wav...@gmail.com> wrote:
> --
> 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
Reply all
Reply to author
Forward
0 new messages