There is a custom among Java administrators to set -Xms to the same value as -Xmx. I have long wondered what the effect of this could be. Hearsay suggests that this keeps the JVM from repeatedly allocating and de-allocating memory, thus reducing the memory allocation overhead. Unfortunately I have been unable to find any measurements that suggest that doing this makes any difference.
As you may or may not know, Java works with fixed size memory pools. The memory for those pools is allocated by requesting chunks or memory from the operating system.
You can see this in action by watching the memory graphs, where the red line indicates the configured maximum memory to use. The green line shows the actual fill level of the memory pool. The blue line is what Java has requested from the operating system so far. It shows how Java requests and returns memory over time.
Well, I have been running with -Xmx set to 1GB for a long time and recently I figured I would experiment with also setting -Xms to the same value and see for myself what happens. In short, setting -Xms does what it says on the box: it sets the initial memory pool sizes to the value. After that, Java just resumes its normal behaviour of allocating memory. This can be seen in the memory graph below.
As you can see, when we specify -Xms to be the same as -Xmx, the blue line immediately starts out at the maximum level. It stays up there for a while, but after a while the blue line drops sharply. From then on, Java does what is always does: allocate and de-allocate memory from the operating system.
This behaviour seems to be controlled from the PS MarkSweep garbage collector. As you can see in the graph below, Java leaves the committed memory (relatively) untouched, until a full GC is performed. The first PS MarkSweep (which does full garbage collects) spike coincides with the sharp drop in committed memory. In the full GC, it ignores the -Xms setting and returns a large portion of the freed memory to the operating system.
So, to summarise: feel free to keep setting -Xms to match -Xmx if you like. It won't make any difference for a server which runs for longer periods of time.
PS. Yes, the blue line sometimes crosses up higher than the red line. I don't know why that is, but I believe that Java requests memory in certain fixed size blocks. The crossings may indicate rounding artefacts, where Java decides it is better to ask just a little more so that it can fill an entire block. This is just speculation, tough, so don't take it from me.