question about the memory used in nodejs

96 views
Skip to first unread message

Zidong Jiang

unread,
Mar 26, 2015, 3:04:28 PM3/26/15
to nod...@googlegroups.com
Hi, I have a question about the memory used in nodejs

When I call process.memoryUsage in a node without any third-party modules, it shows

> process.memoryUsage()
{ rss: 11296768,
  heapTotal: 7195904,
  heapUsed: 2964776 }

I think the heapTotal(7K) is included in the RSS(11K), and heapTotal is consumed by v8. is it right?

Which parts of nodejs mainly occupy the remaining 11-7=4K memory?

Luca Morandini

unread,
Mar 27, 2015, 1:02:26 PM3/27/15
to nod...@googlegroups.com
On 26/03/15 16:34, Zidong Jiang wrote:
>
> I think the heapTotal(7K) is included in the RSS(11K), and heapTotal is consumed
> by v8. is it right?

Yes and no, the whole RSS is used by V8, but only heapUsed is currently used to
hold JavaScript objects. By the way, those are MBytes, not KBytes.


> Which parts of nodejs mainly occupy the remaining 11-7=4K memory?

Mainly buffers used during I/O.

Regards,

Luca Morandini
Data Architect - AURIN project
Melbourne eResearch Group
Department of Computing and Information Systems
University of Melbourne
Tel. +61 03 903 58 380
Skype: lmorandini

Zidong Jiang

unread,
Mar 31, 2015, 7:51:03 AM3/31/15
to lmora...@ieee.org, nod...@googlegroups.com
Hi, 

The memory tools you suggested are used for heap analysis and  leak-detection.
They are mainly measuring the memory used by js project (js files).

But I want to know the memory used by node itself. Which parts use the remaining 4M, and how much does one part use.

Thanks
Zidong


2015-03-31 15:45 GMT+08:00 Luca Morandini <luca.mo...@gmail.com>:
On 31/03/15 17:23, Zidong Jiang wrote:

/1, "the whole RSS is used by V8"?/
I think the RSS(11M) is used by the whole nodejs,

You're right, my statement was inaccurate.


and heapTotal(7M) is used by V8.
V8 creates certain heaps to store js object, map, code and so on..
And heapUsed(3M) is the size of current used size of heap. The remaining part of
heap(7-3=4M) is empty, but reserved by v8. Is that right?

Yes.


/2, The remaining memory(11-7=4M), "Mainly buffers used during I/O. "/
Because when I check the memoryUsage, nodejs haven't run any file yet. In my
understanding, those part memory is used by c/c++ part of nodejs and libs in
/deps, including the v8. (running v8 itself needs memory)
what does / "buffers used during I/O." mean?/

When Node,js executes I/O operations, data read/written have to be buffered somehow, and that's not done in the heap.


3, do you know any methods/tools to know the memory distribution of nodejs?  how
many is used by linuv, by v8 itself, by openssl ...

node-heapdump , node-memwatch , and  StrongLoop Arc
https://strongloop.com/strongblog/node-js-performance-heap-profiling-tip/

Zidong Jiang

unread,
Mar 31, 2015, 7:51:52 AM3/31/15
to nod...@googlegroups.com, lmora...@ieee.org
Sorry that I mistaked the MB as KB.

I don't fully understand your answer.

1, "the whole RSS is used by V8"?
I think the RSS(11M) is used by the whole nodejs, and heapTotal(7M) is used by V8. V8 creates certain heaps to store js object, map, code and so on..
And heapUsed(3M) is the size of current used size of heap. The remaining part of heap(7-3=4M) is empty, but reserved by v8. Is that right?

2, The remaining memory(11-7=4M), "Mainly buffers used during I/O. "
Because when I check the memoryUsage, nodejs haven't run any file yet. In my understanding, those part memory is used by c/c++ part of nodejs and libs in /deps, including the v8. (running v8 itself needs memory)
what does  "buffers used during I/O." mean?

3, do you know any methods/tools to know the memory distribution of nodejs?  how many is used by linuv, by v8 itself, by openssl ...


在 2015年3月28日星期六 UTC+8上午1:02:26,Luca Morandini写道:

Luca Morandini

unread,
Mar 31, 2015, 10:36:28 PM3/31/15
to nod...@googlegroups.com
On 31/03/15 19:32, Zidong Jiang wrote:
> Hi,
>
> The memory tools you suggested are used for heap analysis and leak-detection.
> They are mainly measuring the memory used by js project (js files).
>
> But I want to know the memory used by node itself. Which parts use the remaining
> 4M, and how much does one part use.

This is something core developers shuold know: you may have some luck asking the
io.js developers on Stack Overflow
http://stackoverflow.com/questions/tagged/io.js
Reply all
Reply to author
Forward
0 new messages