The performance of setting the initial and maximum Java memory to the same value

In my working environment, we have a number of Enterprise Java applications that run on Windows Server 2008 hardware. An external consultant studied the performance of our Java applications and suggested changing the initial and maximum memory values ​​so that they are identical.

So, currently we are launching the application with 1 GB of initial and 2 GB of maximum memory. Their recommendation is to change the initial and maximum memory to both 2 GB.

Their reasoning is 2 times ...

  • By highlighting the initial and maximum values ​​of 2 GB, when a Java application starts, it will capture a 2 GB memory block. This prevents other applications from accessing this block of memory, so this memory will always be available for a Java application. This contradicts the current situation when he receives a 1 GB initial block, which means that potentially other applications can consume the remaining available memory on the server, and a corporate Java application will not be able to grow up to 2 GB of maximum memory.
  • Every time Java needs to allocate memory between the initial and maximum sizes, there is a slight increase in performance. This is due to the fact that he needs to go to Windows, assign a new block of the required size, and then use it. This performance hit will occur every time memory is required between the initial size and the maximum size. Therefore, setting them both to the same value means that this impact on performance has been eliminated.

, , , Java , . , , , , , , .

, , 2, , , . , , Java, .

- , , . - ?

+3
4

​​ . , GC , , , , . . , , . 2 , , 400 , , 100 , . , . , , .

# 1 , , , . , , . . , 2 , 4 . / , , .

+3

, . . , 2 Java-, , 2 . , , , .

+3

2- . - -. . 2 - . ? , .

, , , 2 . . , , 2 , , - .

, , , . , 2 .

, ... . REAL . , .

+2

JVM, , . . e..g 2G 2G. . ( , )

. , JVM ( , )

The real impact is that the small heap size can cause temporary objects to move into a space that is expensive to clean. A larger heap size may mean that temporary objects are discarded many times before being copied and deleted with full gc.

+1
source

All Articles