A method to get memory profiles that works?

263 views
Skip to first unread message

Axel Kittenberger

unread,
Aug 3, 2012, 12:48:54 PM8/3/12
to nodejs
Dear all,

Since my node server needs far more memory than I think it should, I
tried to get a memory profile of it.
How do I get it? Something that works? (node v0.8.5, viewing in Chrome
20.0.1132.57)

for example I followed the tutorial at
https://github.com/felixge/node-memory-leak-tutorial

It all looks nice, except for me there is no profile button

I tried

var profiler = require('v8-profiler');
...
console.log(util.inspect(profiler.takeSnapshot('1')));

and get

node: symbol lookup error:
/home/axel/meshcraft/node_modules/v8-profiler/build/Release/profiler.node:
undefined symbol: _ZNK2v813HeapGraphNode17GetRetainersCountEv

bnoordhuis profiler ( https://github.com/bnoordhuis/node-profiler )
looks to do CPU only (that works! but now what I need)

Now I do not know what else to try, help!

Kind regards,
Axel

Diogo Resende

unread,
Aug 3, 2012, 12:53:05 PM8/3/12
to nod...@googlegroups.com

-- 
Diogo Resende

--
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
For more options, visit this group at

Axel Kittenberger

unread,
Aug 3, 2012, 1:06:42 PM8/3/12
to nod...@googlegroups.com
> http://nodetime.com/

I forgot to mention that, nope, basically work, but the output is far
off and honestly I don't really want to upload my memory dumps to some
offsite service

Jimb Esser

unread,
Aug 3, 2012, 9:39:47 PM8/3/12
to nod...@googlegroups.com
v8-profiler and node-profiler haven't been updated for newer versions of V8, I think. Have you tried node-webkit-agent?
Seems to work well for CPU and JS heap profiling for us when the others stopped working.

Axel Kittenberger

unread,
Aug 4, 2012, 1:37:25 PM8/4/12
to nod...@googlegroups.com
> v8-profiler and node-profiler haven't been updated for newer versions of V8,
> I think. Have you tried node-webkit-agent?
> https://github.com/c4milo/node-webkit-agent

Thank you, node-webkit-agent works! \o/

Can somebody explain me the possibilities of a discrepancy in memory
use? According to 'top' my node server process needs 92mb of reserved
memory.

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
27996 axel 20 0 639m 92m 6048 S 0.0 2.4 0:06.06 node

I also tested with a minimal "hello world" mini-webserver. With it
node needs 10mb RES on my system.

The heap in the profile reports 9mb of total use.
http://i.imgur.com/hZ7QP.png

What are the other 73mb? Any idea I can track that down?

On my computer it bein 2% sounds like nitpicking, but the VM i bought
the server runs on has 512MB so I don't want to explode it. Or rather
I'd like to know how much of the memory is "fixed" and how much is due
to the data i keep in memory of my processing. That is, I'd like to be
able to estimate how well it will (web)scale. I first thought the 92mb
were mostly due to my data, which would've ment it scales badly, but
if its only 100kb as I read the profile, it should scale well. Are the
70mb libraries through require? I tested to require them in the mini
server as well, but didn't change much. Maybe they just get collected
soon after.

Kind regards,
Axel

Axel Kittenberger

unread,
Aug 4, 2012, 4:37:35 PM8/4/12
to nod...@googlegroups.com
> Can somebody explain me the possibilities of a discrepancy in memory
> use?

Never mind me. I shouldn't treat a garbage collected language like I
used to the days with classical memory management. With --expose-gc
and calling gc() in strategic places during startup at my discretion
reduces the resulting reserved memory use to 27mb instead of the
default 100mb. Lesson learned: reserved memory means nothing nowadays,
everything was just fine.

Kind regards, Axel

Marcel Laverdet

unread,
Aug 4, 2012, 6:11:41 PM8/4/12
to nod...@googlegroups.com
RES stands for resident, not reserved. "Reserved" sounds closer to virtual memory. RSS/RES should be meaningful representations of the physical amount of memory your application needs.


Kind regards, Axel

Reply all
Reply to author
Forward
0 new messages