0

I have a java spring boot service running as java -Xms1024m -Xmx6144m. When the service first starts the server (k8s pod) shows memory around 2.5GB and after a load it get increase to like 7GB and stays that value even after no load. Max memory pod can goes it 8GB. Below is how NR looks as of now. The JVM actually memory consumption is around 2990MB only.

enter image description here

enter image description here

Even Garbage collector ran for like 1 mint still the PS Used old gen heap also didn't get reduced. That means the service consume that memory memory anyway.

enter image description here

I assume its because the xms value of 6GB set at start up java command and it cause committed heap to be set as 6GB shown in NR. But then why the pod memory is not shows as around 7GB just after deploy when running without load. Should not the pod memory has to be reduce back since jvm only consume 2990MB only?

Harshana
  • 7,297
  • 25
  • 99
  • 173
  • `-Xms1024m` is your starting heap size for the JVM. It can grow up to `-Xmx6144m` as needed. JVMs tend not to relinquish memory back to the OS, but keep it around as available for heap. – Taylor Jan 24 '22 at 17:02
  • Why jvm not release the memory back to the OS if the real memory usage is only 2.9GB? – Harshana Jan 24 '22 at 17:05
  • https://stackoverflow.com/questions/30458195/does-gc-release-back-memory-to-os – Taylor Jan 24 '22 at 17:07
  • @Taylor In such situation we would face issues when set memory as a metric for auto scale know since it would trigger auto scale always even without load – Harshana Jan 26 '22 at 13:20
  • So depending on what auto-scale you're using, you should be able to trigger it based on heap usage. This isn't uncommon. – Taylor Jan 26 '22 at 17:48

0 Answers0