title: Java process consuming 90% of swap space
body: <p>I have an application that has an allocated heap memory of 20GB. But even though the Heap memory is barely or less than 50% used, my server swap space gets used up totally. Java is the process that is consuming 90% of the swap.</p>
  
  <p>The swap gets released only after restarting the application with a below warning. Looking for finding out the root cause and any impact due to this. Will my app fail to start if the swap is filled?</p>
  
  <p><strong>Warning i see during App startup in logs</strong>:</p>
  
  <blockquote>
    <p>There is insufficient memory for the Java Runtime Environment to continue.
     Native memory allocation (mmap) failed to map 17895718912 bytes for committing reserved memory.. Out of swap space or heap resource limit exceeded (check with limits or ulimit)?
     An error report with more information is generated,
     it is saved as a file at this location:
     /XX/myapp/apache-tomcat-7.0.90/bin/hs_err_pid86282.log
    2020-01-14T05:17:18.742+0100 [INFO] [o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker] Bean '(inner bean)#1814a032' of type [org.springframework.aop.aspectj.AspectJAroundAdvice] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    ***Warning: INFO: os::commit_memory(0x00000003fjgh0000, 17895718912, 0) failed; error='Not enough space' (errno=12)
     There is insufficient memory for the Java Runtime Environment to continue.
     Native memory allocation (mmap) failed to map 17895718912 bytes for committing reserved memory.. Out of 
     swap space or heap resource limit exceeded (check with limits or ulimit)?
     An error report with more information is generated,
     it is saved as a file at this location:</p>
  </blockquote>
  
  <p><strong>My JVM properties</strong>:</p>
  
  <pre><code>/XX/java/bin/java -Djava.util.logging.config.file=/XX/myapp/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -javaagent:/xx/myapp/newrelic/newrelic.jar -Djdk.tls.ephemeralDHKeySize=2048 -Xms20g -Xmx20g -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+AlwaysPreTouch -XX:+DisableExplicitGC -XX:+CMSIncrementalMode -XX:+CMSIncrementalPacing -Djava.net.preferIPv4Stack=true -Dignore.endorsed.dirs= -classpath /XX/myapp/tomcat/bin/bootstrap.jar:/XX/myapp/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/XX/myapp/tomcat -Dcatalina.home=/XX/myapp/tomcat -Djava.io.tmpdir=/XX/myapp/tomcat/temp org.apache.catalina.startup.Bootstrap start
  </code></pre>
  
  <p>Swap usage when checked for each process, its Java that uses 90% of Swap</p>