On Fri, Mar 16, 2012 at 00:49, Jimb Esser <[email protected]> wrote:
> We have some servers running node.js under Ubuntu.  After a day or two
> of running, once and a while, a node process will be using something
> like 4gb of memory.  process.memoryUsage() indicates something like
> rss: 4gb, heapTotal: 50mb, heapUsed: 40mb, so the memory is not in
> anything a V8 heap snapshot would show me.  There are lots of possible
> culprits (Buffers, any number of things native modules are allocating
> - I'm 90% certain I know which module, but no idea where/what
> specifically).
>
> So, my general question, how do people go about debugging memory leaks
> in native code in node (or node itself)?
>
> Coming from PC development, I'm familiar with 101 ways to skin a heap
> on windows, but haven't the slightest idea on Linux in general (and a
> bunch of the native modules we use do not work on Windows since node
> stopped supporting cygwin, so no short term/easy solutions there -
> plus this only happens after days on our production Linux servers).
> I'd heard good things about Google's perftools' heap profiler, but I
> attempted to link Node with that and it simply segfaulted very shortly
> after startup.

In development environments, valgrind is the way to go. That won't
help in production because it's unbearably slow (essentially your code
runs inside a virtual machine that tracks every read and write).

I have had moderate success with making the process dump core and do a
post-mortem inspection of the heap in gdb. Use `gcore` or a simple
`kill -QUIT <pid>` to dump core, set `ulimit -c unlimited` before you
start the process.

-- 
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to