title: Error while fetching 100K records from mongodb in Scala using Akk-Http
body: <p>I've written following code to fetch records and perform action</p>
  
  <p>On akka-http route,</p>
  
  <pre><code>complete(mongoDB.getCollection(getCollectionName(user_id, list_id)).find()
      .getAllContacts(user_id, list_id).map { line =&gt;
          validateNumber(line.phone, prefixTrim)
      }.toFuture().map(_.size.toString))
  </code></pre>
  
  <p>On testing the API with wrk with 1000 connection and 10 threads, I'm getting following errors</p>
  
  <pre><code>java.lang.OutOfMemoryError: GC overhead limit exceeded
   Error during processing of request: 'Boxed Error'. 
  Completing with 500 Internal Server Error response. 
  To change default exception handling behavior, provide a custom ExceptionHandler.
  java.util.concurrent.ExecutionException: Boxed Error
  
  Caused by: java.lang.OutOfMemoryError: Java heap space
  </code></pre>
  
  <p>Is there anyway to resolve this issue without increasing heap size?</p>
  
  <p>UPDATED</p>
  
  <p>The collection size = 33MB
  and</p>
  
  <pre><code>java -XX:+PrintFlagsFinal -version | grep -iE 'heapsize|permsize|threadstacksize'
       intx CompilerThreadStackSize                   = 0                                   {pd product}
      uintx ErgoHeapSizeLimit                         = 0                                   {product}
      uintx HeapSizePerGCThread                       = 87241520                            {product}
      uintx InitialHeapSize                          := 268435456                           {product}
      uintx LargePageHeapSizeThreshold                = 134217728                           {product}
      uintx MaxHeapSize                              := 4294967296                          {product}
       intx ThreadStackSize                           = 1024                                {pd product}
       intx VMThreadStackSize                         = 1024                                {pd product}
  java version "1.8.0_131"
  </code></pre>