I have an Ubuntu 18.04 VM image that runs a Java 8-based server process. When running on a single core EC2
t2.small instance (2GB RAM) it starts with an RSS of 432M. Running the exact same server image as a
t3.small (dual core, same 2GB RAM), the service rockets up to 876M RSS on start. On Java 10, the difference is even more profound: sometimes it starts at 1586M RSS. And performance takes a noticeable hit.
At no point is any swap being used.
Exact same server image, very different results. The only significant variable seems to be the number of cores.
HOWEVER after running
jmap to see how the heap's being used, I noticed the RSS had fallen by half, about where I'd expect it to be on the t2. And the heap dumps showed no real difference in actual allocation across t2 or t3, Java 8 or Java 10.
So, I'm wondering: is this the JVM or OS that's acting differently? I know I can play with
MaxHeapFreeRatio to get the JVM to release memory quicker, but is this the JVM reacting to memory conditions, or the OS?