title: How to prevent Huge Aggregate Queries from crashing MongoDB?
body: <p>I have a MongoDB instance where sometimes previously unexpected queries need to be made. (That's the whole point of schema-less, right?)</p>
  
  <p>Some of these are very complex and therefore take a long time. This is fine with me, but what I'm struggling with is these queries crashing Mongod service itself.</p>
  
  <p>I would think a natural way to handle these cases would be simply timeout or reject the query, but looks like Mongod just crashes (The kernel kills mongod process with OOM error)</p>
  
  <p>This is frustrating because this comes without warning. I am aware that MongoDB leaves memory management to the OS, so i'm confused why it allows this type of crashes to happen.</p>
  
  <p>Is there an easy way to deal with this type of situation?</p>