title: what happens if the java heap memory limits is different than the pod resource limits in kubernetes?
body: <p>I'm running a spring boot inside a pod with the below configurations.</p>
  
  <p>Pod limits:</p>
  
  <pre><code>resources:
      limits:
        cpu: "1"
        memory: 2500Mi
      requests:
        cpu: "1"
        memory: 2500Mi
  </code></pre>
  
  <p>command args:</p>
  
  <pre><code>spec:
  containers:
  - args:
    - -c
    - ln -sf /dev/stdout /var/log/access.log;java -Dcom.sun.management.jmxremote
      -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.authenticate=false
      -Dcom.sun.management.jmxremote.ssl=false -Djava.security.egd=file:/dev/./urandom
      -Xms1600m -Xmx1600m -XX:NewSize=420m -XX............
  </code></pre>
  
  <ol>
  <li>What happens if the java process has reached its max heap limit (i.e 1600m (Xmx1600m))</li>
  <li>If Xmx has no effect on the java process inside a pod, it can go up to pod limit right (i.e. memory: 2500Mi of limits section)</li>
  <li>If the above configurations are correct, then we are wasting 900Mi of memory right (2500-1600=900)</li>
  </ol>