Java Reference
In-Depth Information
5. On many versions of Linux, the amount of huge page memory that a user can allocate
is limited. Edit the /etc/security/limits.conf file and add memlock entries for the user
running your JVMs (e.g., in the example, the user appuser ):
appuser soft memlock 4613734400
appuser hard memlock 4613734400
If the limits.conf file is modified, the user must log in again for the value to take effect. At
this point, the JVM should be able to allocate the necessary huge pages. To verify that it
works, run the following command:
# java -Xms4G -Xmx4G -XX:+UseLargePages -version
java version "1.7.0_17"
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
Successful completion of that command indicates that the huge pages are configured cor-
rectly. If the huge page memory configuration is not correct, a warning will be given:
Java HotSpot(TM) 64-Bit Server VM warning:
Failed to reserve shared memory (errno = 22).
Linux transparent huge pages
Linux kernels starting with version 2.6.32 support transparent huge pages, which obviate the
need for the configuration described above. Transparent large pages must still be enabled for
Java, which is done by changing the contents of /sys/kernel/mm/transparent_hugepage/en-
abled :
# cat /sys/kernel/mm/transparent_hugepage/enabled
always [madvise] never
# echo always > /sys/kernel/mm/transparent_hugepage/enabled
# cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never
The default value in that file (shown in the output for the first command) is madvise —huge
pages are used only for programs that explicitly advise the kernel they will be using huge
pages. The JVM does not issue that advisory, so the default value must be set to always (by
Search WWH ::




Custom Search