Enhanced Linux Memory Defragmentation
This section addresses the situation when Azul Zulu Prime Builds of OpenJDK (Azul Zulu Prime JVM) fails with one of the following error messages:
Memory management: unable to fund java heap account
ERROR: perror: az_pmem_reserve_pages (num2mPages …
As these errors can occur when not enough free memory is available, i.e. other large processes are already running, first check with the command
zing-ps -s and
top if other Azul Zulu Prime JVM or other large processes are already running.
If enough free memory is available as indicated by the Linux
free command, then the cause of these error messages is often memory fragmentation. Azul Zulu Prime JVM needs large Linux pages of at least 2 MB page size and those might be too fragmented.
If rebooting the system is not an acceptable solution in this case, upgrade to at least Azul Zulu Prime System Tools (ZST) 5.21.7 and add the following line to the file
With this setting Azul Zulu Prime JVM’s enhanced Linux memory defragmentation is enabled to be able to operate under situations of high fragmentation.
Do not enable the
RESERVE2MB=true enables Linux memory defragmentation. This Linux function causes all processes on the host to stop for a few ms to seconds depending on the RAM size if defragmentation is triggered.
When using this setting with the ZST mode reserve-at-config, the memory initialization and potential triggering of the defragmentation happens only during the start of the ZST system service zing-memory. It is safe to enable this setting there if you do not restart the zing-memory system service during the operation of other business applications on your host.
Alternatively, you can run Azul Zulu Prime JVM without ZST (possible since Azul Platform Prime 19.07.0.0) or update your operating system to a version with Linux kernel 4.4 or newer, where the
RESERVE2MB setting is not needed anymore.
When enabling the
RESERVE2MB setting in combination with the ZST mode reserve-at-launch, it can trigger the defragmentation potentially on each start of a Java process. Depending on the application use case, it is often acceptable, for example, if Java process starts occur during non-business hours only.
With reserve-at-launch and the
RESERVE2MB setting, there exists an additional small risk of triggering the defragmentation even during runtime of a Java process when it consumed all the available contingency or pause prevention memory and is requesting more. To prevent triggering the defragmentation during runtime, set the pause prevention and contingency memory pools to a static value, for example, each to 3% of the system RAM in the
file/etc/zing/pmem.conf and restart the zing-memory system service:
ContingencyUpperLimit 3% ContingencyMinimumFreeMemory 3% PausePreventionUpperLimit 3% PausePreventionMinimumFreeMemory 3%