title: Tomcat Server unresponsive "http-nio-80-Acceptor-0"
body: <p>I've a spring boot(1.5.8.RELEASE) app running with 5GB RAM. When I hit the API with some request returning huge data it throws</p>
  
  <pre><code>&gt; Apr 30, 2020 2:01:34 PM org.apache.catalina.core.StandardWrapperValve invoke
  SEVERE: Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.OutOfMemoryError: GC overhead limit exceeded] with root cause
  </code></pre>
  
  <p>The above exception is expected as the data size is huge and application is running out of memory. But if I hit API with the same request returning huge data my application throws the following exception and app becomes unresponsive and I need to restart it every time. But if I again hit the API with request returning less amount of data it works perfectly fine.</p>
  
  <pre><code>Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "http-nio-80-Acceptor-0"
  Exception in thread "ContainerBackgroundProcessor[StandardEngine[Tomcat]]" java.lang.OutOfMemoryError: GC overhead limit exceeded
  Apr 30, 2020 2:09:22 PM org.apache.catalina.core.StandardWrapperValve invoke
  SEVERE: Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.OutOfMemoryError: GC overhead limit exceeded] with root cause
  java.lang.OutOfMemoryError: GC overhead limit exceeded
  </code></pre>
  
  <p>Why is it throwing different exceptions for the same request? I analyzed memory using VisualVm memory was immediately getting clear after processing of requests and I've made sure there is no memory leak. Does this has something to do with <code>org.apache.tomcat.jdbc.pool.DataSource()</code> that I'm using?</p>