title: Spring boot memory utilization
body: <p>We have an application based on Spring Boot.  We deploy it using an executable jar which is about 20Meg.  When we start this application, it uses 18Gigs worth of "Virutual" memory right away.  I understand that most of this is kept in secondary storage such as hard disk, but our System Administrators are questioning why we need so much of Virtual memory.</p>
  
  <p>The Jar file is small.  At the startup I am using BoneCPDataSource but I've cut down # of connections to 5.  As soon as application is started it uses 18g of Virtual memory.</p>
  
  <p>Can someone tell me why?  Should I play with java memory settings on command line to reduce this number?  The command we use is:</p>
  
  <p>java -jar filename.jar</p>
  
  <p>As requested, here's some more info:</p>
  
  <p>1) Here's a line from 'top' command:<br><br>
  24511 xyz  20   0 17.6g 531m 9.8m S  0.0  0.8   0:16.57 java</p>
  
  <p>2)  There's no Neo4J.  Here's my pom.xml</p>
  
  <p>
  http://maven.apache.org/xsd/maven-4.0.0.xsd">
      4.0.0</p>
  
  <pre><code>&lt;groupId&gt;com.xyz.myapp&lt;/groupId&gt;
  &lt;artifactId&gt;myapp-rest-service&lt;/artifactId&gt;
  &lt;version&gt;0.1.0&lt;/version&gt;
  
  &lt;properties&gt;
      &lt;start-class&gt;com.xyz.myapp.rest.Application&lt;/start-class&gt;
  &lt;/properties&gt;
  
  &lt;parent&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
      &lt;version&gt;1.0.1.RELEASE&lt;/version&gt;
  &lt;/parent&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.jolbox&lt;/groupId&gt;
          &lt;artifactId&gt;bonecp&lt;/artifactId&gt;
          &lt;version&gt;0.8.0.RELEASE&lt;/version&gt;
          &lt;exclusions&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;com.jolbox&lt;/groupId&gt;
                  &lt;artifactId&gt;com.jolbox.logging&lt;/artifactId&gt;
              &lt;/exclusion&gt;
          &lt;/exclusions&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
          &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt;
          &lt;version&gt;4.0.3.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-tx&lt;/artifactId&gt;
          &lt;version&gt;4.0.3.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.logging.log4j&lt;/groupId&gt;
          &lt;artifactId&gt;log4j-api&lt;/artifactId&gt;
          &lt;version&gt;2.0-rc1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.logging.log4j&lt;/groupId&gt;
          &lt;artifactId&gt;log4j-core&lt;/artifactId&gt;
          &lt;version&gt;2.0-rc1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;oracle&lt;/groupId&gt;
          &lt;artifactId&gt;jdbc&lt;/artifactId&gt;
          &lt;version&gt;6.0&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-security&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-bundle&lt;/artifactId&gt;
          &lt;version&gt;1.18.1&lt;/version&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt; 
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt; 
              &lt;version&gt;2.3.2&lt;/version&gt; 
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  
  &lt;repositories&gt;
      &lt;repository&gt;
          &lt;id&gt;spring-snapshots&lt;/id&gt;
          &lt;url&gt;http://repo.spring.io/libs-snapshot&lt;/url&gt;
          &lt;snapshots&gt;&lt;enabled&gt;true&lt;/enabled&gt;&lt;/snapshots&gt;
      &lt;/repository&gt;
  &lt;/repositories&gt;
  
  &lt;pluginRepositories&gt;
      &lt;pluginRepository&gt;
          &lt;id&gt;spring-snapshots&lt;/id&gt;
          &lt;url&gt;http://repo.spring.io/libs-snapshot&lt;/url&gt;
          &lt;snapshots&gt;&lt;enabled&gt;true&lt;/enabled&gt;&lt;/snapshots&gt;
      &lt;/pluginRepository&gt;
  &lt;/pluginRepositories&gt;
  </code></pre>
  
  <p></p>
  
  <p>3)  I build this application using following command:</p>
  
  <p>mvn clean package</p>
  
  <p>and this is what it creates in the ./target directory:</p>
  
  <p>-rwxr-xr-x  1 myuserid Domain Users 20259555 Jun  9 15:36 myapp-rest-service-0.1.0.jar</p>
  
  <p>4)  lsof output for my app:</p>
  
  <p><a href="http://pastebin.com/V00BrD67" rel="noreferrer">http://pastebin.com/V00BrD67</a></p>
  
  <p>5)  Output from mvn dependency:tree</p>
  
  <p><a href="http://pastebin.com/cFnR0NMX" rel="noreferrer">http://pastebin.com/cFnR0NMX</a></p>