title: GAE using much more memory than my Java application
body: <p>I have a Java app (Spring Boot) running on Google App Engine; however, I see weird differences between my Java app memory consumption and the dashboard shown by GAE.</p>
  <p>In my local machine using a VisualVM I can see it doesn't consume over 100MB even at peak times, and I added a servlet to return the amount of memory used:</p>
  <pre class="lang-java prettyprint-override"><code>@GetMapping(&quot;/&quot;)
  public String index() {
    Runtime rt = Runtime.getRuntime();
    long total = rt.totalMemory();
    long free = rt.freeMemory();
    long used = total - free;
    return &quot;Total: &quot; + total / 1024 / 1024 + &quot;MB&lt;br&gt;Used: &quot; + used / 1024 / 1024 + &quot;MB&lt;br&gt;Free: &quot; + free / 1024 / 1024 + &quot;MB&quot;;
  }
  </code></pre>
  <p>my deployed app in GAE right now returns:</p>
  <pre><code>Total: 91MB
  Used: 69MB
  Free: 21MB
  </code></pre>
  <p>at this same time, the GAE dashboard shows it's consuming around 350MB
  <a href="https://i.stack.imgur.com/Dkbjh.png" rel="nofollow noreferrer">memory dashboard IMG url</a></p>
  <p>Why did that happen? It forces me to use an F2 instance; if I downgrade to an F1, it keeps failing and restarting.</p>
  <p>I noticed that once I changed my cronjob from every 30 min to run every 2 min, they started charging me for 40 hours per day in Frontend instances, it was around 16 hours before this change, and I have only 1 instance running. How is that possible?
  <a href="https://i.stack.imgur.com/C9jJw.png" rel="nofollow noreferrer">instance count img url</a></p>
  <p>Thank you</p>