title: NodeJs: running spawn process memory usage is growing
body: <p>I use the follow code to run a PHP script in CLI environment within a nodejs server. 
  The script takes the data in stdin performs the calculations and return other data to stdout.</p>
  
  <p>The problem is that to run the script with <strong>child_process.spawn</strong> and pipes to an <strong>increasing memory usage</strong>. So I must to restart the node app every little time.</p>
  
  <p>I would like to keep constant the use of RAM.</p>
  
  <p>In the example I use <em>cat</em> command to simulate my php script, but the problem persists, <strong>increasing use of memory</strong> proportional to the number of cycles in setInterval.
  And I use <em>setInterval</em> to simulate period execution of the script.</p>
  
  <pre><code>var spawn = require('child_process').spawn;
  
  var php = spawn('cat');
  
  var i = 0;
  setInterval(function() {
      php.stdin.write(++i);
  },10);
  </code></pre>
  
  <p><strong>case #2</strong>
  I see a memory leak even with:</p>
  
  <pre><code>var spawn = require('child_process').spawn;
  
  var php = spawn('cat');
  php.stdout.resume();
  php.stderr.resume();
  
  var i = 0;
  setInterval(function() {
    gc &amp;&amp; gc();
    console.log(process.memoryUsage());
    console.log(php.stdin.write(''+(++i)));
  },1000);
  </code></pre>
  
  <p>executed with: <em>node --expose-gc --always-compact foo.js</em></p>
  
  <p>tested for node both v0.10.28</p>