Why is the JVM program much faster with smaller heap settings?

I am comparing a JVM application that is very heavy on both IO and CPU.

Usually I compare it with a heap size of 4G max / min, the whole control suit takes an average of 73 seconds to run.

Today I was curious, and I gave him only 1 GB max / min. Heap size, and surprisingly, the entire test suit takes just 62 seconds to work on average.

So, I wonder why the JVM works better with a smaller heap size?

Additional notes:

Environment:

java version "1.7.0_19" OpenJDK Runtime Environment (fedora-2.3.9.1.fc17-x86_64) OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode) Linux ____ 3.8.4-102.fc17.x86_64 #1 SMP Sun Mar 24 13:09:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux 
+4
source share
1 answer

The Oracle JVM docs in the note say:

Then you can try to reduce the amount of heap used. A large heap will increase the pause of garbage collection, since there is more heap to scan.

This is also a feature of the GC algorithm that you use. For example, incremental GC can give completely different numbers. (Try -Xincgc and see your numbers)

link

+3
source

All Articles