how to get a child process memory usage in node.js?

I know there is a api process.memoryUsage() to get memory usage in current process.

But if I start a new child process by child_process.spawn(command, [args], [options]) and I get a ChildProcess object, then how can I get the new process memory usage?

Well you can use ps(uses /proc/<pid>/stat underlying) if you are in a unix environment. Here's an example:

// Spawn a node process
var child_process = require('child_process');
var child = child_process.spawn('node');

// Now get its pid.
child_process.exec('ps -p' + child.pid + ' -o vsize=',  function (err, stdout, stderr) {
  err = err || stderr;
  if (err) {
      return console.log('BAD Luck buddy: ', err);
  }
  console.log('YOU\'ve done it', parseInt(stdout, 10));
});

This is tested with ubuntu 12.04 and OS X lion. Though don't think it'll work in windows.