-1

I have specified the -Xms and -Xmx values as the same say 4GB. Now when I start my spring-boot application, I was under my assumption that OS will allocate 4GB of memory right after starting the application since that is the value specified using the -Xms argument. But when I checked the Resident Set of the application and also heap memory(using JMX), I can see memory allocated is still less than 1GB. So does that mean OS does not necessarily allocate memory specified using -Xms.

Thanks in advance.

CrazyCoder
  • 2,465
  • 8
  • 36
  • 57

1 Answers1

0

You didn't say which OS and which JVM vendor/version but often OS allocates pages lazily, that is they aren't in RAM ("resident") unless needed. If your application doesn't actually need that heap memory it's not gonna be resident. Also there's "adaptive size policy" that may heap shrink even below "-Xms" if it's occupancy is too low: https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gc-ergonomics.html

Juraj Martinka
  • 3,991
  • 2
  • 23
  • 25