Java Client Applications May Use Significantly More Memory and CPU After Upgrading to JDK 11 or Later from JDK 8 32-bit


Applies to

Java SE JDK and JRE - Version 11 and later
Any platform.


Symptoms

When migrating a small Java client application from Java SE 8 HotSpot 32-bit Client Virtual Machine (VM) to Java SE 11, the following issues may be seen:

  • Significant CPU usage increase, by a factor of 2-3 at application launch
  • Memory footprint increase, by as much as twice
  • Slower start times

Cause

JDK 8 was the last version to offer a 32-bit JDK Client VM, and therefore, upgrading to JDK 11 or later versions means migrating to a 64-bit Server VM. While the Client VM was particularly optimized for smaller applications running in small, single or dual CPU environments, the Server VM is optimized for larger applications to maximize use of resources and optimal performance after startup. See Java Virtual Machine Technology for more information.

Also, the default garbage collector (GC) with JDK 11 is the G1 GC, which requires more CPU and memory resources than the Serial GC that is used with the 32-bit JDK 8 Client VM.


Solution

To improve startup performance and reduce CPU usage, add the flag -XX:+NeverActAsServerClassMachine to your java command line flags and restart the application. This flag emulates the Client VM behavior with the following default configurations:

  • Serial GC is the default GC
  • TieredCompilation is disabled
  • The Client Compiler is used for JIT compilations

To significantly reduce memory footprint, add the java command line flags: -XX:MinHeapFreeRatio=0 -XX:MaxHeapFreeRatio=0

Setting these flags to 0 reduces the committed memory for the Java heap and avoids unnecessary expansion of it during runtime.

Note: While these settings are likely to reduce CPU and memory usage, they might not offer the optimal performance. Make sure to monitor the performance metrics that are of importance to your application and test any configuration changes thoroughly before usage in production.

See Configuration for Client Applications with Oracle JDK 11+ on Poonam Parhar’s blog for more information.


Last reviewed on Sat Feb 01 2025 00:00:00 GMT+0000 (Coordinated Universal Time)