B T
B T

Reputation: 60855

How can I limit memory usage in node.js on the node-side (not OS side)?

I'm getting my processes Killed by the out-of-memory killer. What I'd like to do is tell node "don't use so much memory" and throw an exception if it can't allocate some junk, so that I avoid being killed by the oom killer and potentially can handle it in code. Is this possible? How do I do this?

Upvotes: 0

Views: 440

Answers (1)

mscdex
mscdex

Reputation: 106698

There are various modules on npm that can help you find out what is taking up so much memory.

To start with:

  • node-webkit-agent allows you to do memory (and CPU) profiling and take and compare heap snapshots all within Chrome developer tools.

  • heapdump and a related article about using it here. This can be useful if you don't want/need all of the features of node-webkit-agent and want to periodically save heapdumps to disk from your code.

  • node-inspector for interactive debugging and live inspection of variables and such.

Upvotes: 2

Related Questions