title: Micronaut application memory issues
body: <p>I am trying to use micronaut to create microservices that have a low memory overhead. From using micronaut I've had some issues with the memory starting low, on startup, but ballooning when put under load and not coming back down.</p>
  <p>I am testing it with a small application that takes an item from a rest call, does some work, to simulate a memory spike, and store the results in a database. If I run the jar file the application starts with ~170mb memory and after the induced spike sits around ~700mb. The native image has similar results with albeit lower startup memory. Playing around with the xms and xmx numbers does help the jar version recover after the spike, although it causes the native image to crash during the spike.</p>
  <p>Is this an issue with micronaut? Is there anything I can do to help it recover the memory?</p>
  <p>Below are my tests and results</p>
  <p>Using the micronaut.io/launch to create a java 11 application with kotlin, gradle, and the graalvm plugin. Also I'm using the gradle plugins that are included to build the application and native images.</p>
  <p><code>java -jar build/docker/layers/application.jar</code></p>
  <p>Start up</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>System memory</th>
  <th>heap size</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>~174 mb</td>
  <td>50mb used 264mb total</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>During spike</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>System memory</th>
  <th>heap size</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>~1125 mb</td>
  <td>250mb used 520mb total</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>After spike (which includes a gc call)</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>System memory</th>
  <th>heap size</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>~711 mb</td>
  <td>24mb used 88mb total</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>And with the native image, just the system memory</p>
  <p><code>./build/native-image/application</code></p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>before</th>
  <th>during</th>
  <th>after</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>13mb</td>
  <td>800mb</td>
  <td>800mb</td>
  </tr>
  </tbody>
  </table>
  </div>