title: Express or Node JS memory causes spawn ENOMEM
body: <p>It appears my express server is juicing all the memory on my sever.  I'm only taking a guess at this.  I have a process which is running at:</p>
  
  <pre><code>node server.js
  </code></pre>
  
  <p>This loads a server, receives some data from another server and takes a screen shot.  Everything works and it works for a day or so.  Then out of nowhere, with no code changes it randomly starts crashing with this error:</p>
  
  <pre><code>internal/child_process.js:366
      throw errnoException(err, 'spawn');
      ^
  
  Error: spawn ENOMEM
      at ChildProcess.spawn (internal/child_process.js:366:11)
      at Object.spawn (child_process.js:551:9)
  </code></pre>
  
  <p>I originally had 2 gigs of memory on my server.  The process would work and much faster it would give me this error.  I bumped up the memory to 3 gigs and it lasted a lot longer, over a day and then it started happening again.  Running a check of memory in my server.js file I get this:</p>
  
  <pre><code>{ rss: 30277632,
    heapTotal: 20168704,
    heapUsed: 12109848,
    external: 497984 }
  </code></pre>
  
  <p>From my command line I run:  <code>free -m</code></p>
  
  <pre><code>             total       used       free     shared    buffers     cached
  Mem:          3072       2223        848          3          0       1107
  -/+ buffers/cache:       1115       1956
  Swap:            0          0          0
  </code></pre>
  
  <p>Someone in another post suggested adding swap memory.  Unfortunately on my server provider this doesn't seem possible.  </p>
  
  <p>My guess is that it sucks memory until it runs out then I start getting the error.  Is there anyway I can clean out the memory cache from express to clean up some space?  I'm not too familiar with this. Any ideas?</p>