Chapter 4. JVM tuning


Configuring optimal JVM options for your applications and JBoss EAP environment is one of the most fundamental ways to tune performance. This chapter covers configuring some general JVM options.

Note

Many of the JVM options listed in this chapter can be easily generated using the JVM Options Configuration Tool on the Red Hat Customer Portal.

4.1. Setting a fixed heap size

You must set an appropriate heap size to prevent out of memory errors.

The -Xms option sets the initial heap size, and -Xmx sets the maximum heap size. It is recommended for production environments that you set the initial and maximum heap size options to the same size, so that the heap size is fixed and pre-allocated.

For example, the following options set a 2048 MB heap size:

-Xms2048M -Xmx2048M
Copy to Clipboard

It is recommended that you test your applications under load in a development environment to determine the maximum memory usage. Your production heap size should be at least 25% higher than the tested maximum to allow room for overhead.

4.2. Configuring the garbage collector

Although the parallel garbage collector, also known as the throughput garbage collector, is the default garbage collector in Java 8 for server-class machines, Red Hat recommends using the G1 garbage collector, which is expected to be the default from Java 9 onward. The G1 garbage collector generally performs better than the CMS and parallel garbage collectors in most scenarios.

To enable the G1 collector, use the following JVM option:

-XX:+UseG1GC
Copy to Clipboard

4.2.1. Garbage collection logging options

Garbage collection logging is enabled by default for standalone JBoss EAP servers.

4.3. Enabling large pages

Enabling large pages for JBoss EAP JVMs results in pages that are locked in memory and cannot be swapped to disk like regular memory.

Especially for memory-intensive applications, the advantage of using large pages is that the heap cannot be paged or swapped to disk, and is thus always readily available.

One disadvantage of using large pages is that other processes running on the system might not have quick access to memory, which might result in excessive paging for these processes.

As with any other performance configuration change, it is recommended that you test the impact of the change in a testing environment.

  1. You must ensure that your operating system configuration allows for processes to use large pages.

    • For Red Hat Enterprise Linux systems, you must explicitly configure HugeTLB pages to guarantee that JBoss EAP processes will have access to large pages.
    • For Windows Server systems, the user that is running JBoss EAP must have the large pages privilege assigned:

      1. Select Control Panel Administrative Tools Local Security Policy.
      2. Select Local Policies User Rights Assignment.
      3. Double-click Lock pages in memory.
      4. Add the Windows Server users and user groups that you want to use large pages.
      5. Restart the machine.
  2. Enable or disable large page support:

    • To explicitly enable large page support for JBoss EAP JVMs, use the following JVM option:

      -XX:+UseLargePages
      Copy to Clipboard
    • To explicitly disable large page support for JBoss EAP JVMs, use the following JVM option:

      -XX:-UseLargePages
      Copy to Clipboard
  3. When starting JBoss EAP, ensure that there are no warnings related to reserving memory.

    • On Red Hat Enterprise Linux, an error might look like:

      OpenJDK 64-Bit Server VM warning: Failed to reserve shared memory. (error = 1)
      Copy to Clipboard
    • On Windows Server, an error might look like:

      Java HotSpot(TM) 64-Bit Server VM warning: JVM cannot use large page memory because it does not have enough privilege to lock pages in memory.
      Copy to Clipboard

    If you do see warnings, verify that your operating system configuration and JVM options are configured correctly.

For more information, see the Oracle documentation on Java support for large pages.

4.4. Setting ulimits

For Red Hat Enterprise Linux and Solaris platforms, you must configure appropriate ulimit values for JBoss EAP JVM processes. The "soft" ulimit can be temporarily exceeded, while the "hard" ulimit is the strict ceiling for the usage of a resource. Appropriate ulimit values vary depending on your environment and applications.

If the limits applied to JBoss EAP processes are too low, you will see a warning like the following when starting JBoss EAP:

WARN  [org.jboss.as.warn.fd-limit] (main) WFLYSRV0071: The operating system has limited the number of open files to 1024 for this process; a value of at least 4096 is recommended.
Copy to Clipboard

To see your current ulimit values, use the following commands:

  • For soft ulimit values:

    ulimit -Sa
    Copy to Clipboard
  • For hard ulimit values:

    ulimit -Ha
    Copy to Clipboard

To set the ulimit for the maximum number of open files, use the following commands with the number you want to apply:

  • To set the soft ulimit for the maximum number of open files:

    ulimit -Sn 4096
    Copy to Clipboard
  • To set the hard ulimit for the maximum number of open files:

    ulimit -Hn 4096
    Copy to Clipboard
Note

To guarantee that a ulimit setting is effective, it is recommended on production systems to set the soft and hard limits to the same value.

4.5. Host controller and Process controller JVM tuning

JBoss EAP managed domain hosts have separate JVMs for the host controller and process controller.

You can tune the host controller and process controller JVM settings, but even for large managed domain environments, the default JVM configuration for the host controller and process controller should suffice.

The default configurations for host controller and process controller JVMs have been tested with a managed domain size of up to 20 JBoss EAP hosts each running 10 JBoss EAP servers, for a total domain size of 200 JBoss EAP servers.

If you experience issues with larger managed domains, you might need to monitor the host controller or process controller JVMs in your environment to determine appropriate values for JVM options such as heap size.

Back to top
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2025 Red Hat