Increasing the Jvm Maximum Heap Size for Memory Intensive Applications

Increasing the JVM maximum heap size for memory intensive applications

Get yourself a 64-bit JVM from Oracle.

Can application throughput decrease if the heap size increases?

As you increase the maximum heap size relative to the amount of data that your application actually needs (the live set size) it increases throughput because the Parallel GC has to run less frequently and thus can work more efficiently.

On the other hand if the live set size increases but the maximum heap size remains constant the GC has to run more frequently to achieve increasingly smaller amounts of work, thus decreasing throughput.

Simplified calculations only considering the old generation ahead:

If your program tenures objects at 1GB/s, the collector moves objects at 4GB/s, you give it 100GB of RAM then and you have a live set size of 2GB then it will take 98s to fill up the heap and 0.5s to collect. Application throughput = 99.4%

If your program tenures objects at 1GB/s, the collector moves objects at 4GB/s, you give it 10GB of RAM then and you have a live set size of 2GB then it will take 8s to fill up the heap and 0.5s to collect. Application throughput = 94.1%

If your program tenures objects at 1GB/s, the collector moves objects at 4GB/s, you give it 100GB of RAM then and you have a live set size of 80GB then it will take 20s to fill up the heap and 20s to collect. Application throughput = 50%

How to determine which memory to use for a certain service heap memory?

The exact amount of memory needed for the heap is very specific to the application - you are better of trying multiple configurations and see yourself.

However, needing 4 GB for something that consumes about 600 MB is quite unusual. What are the other things that consume the host memory?

Note that JVM uses much more than just heap memory and this again can vary a lot from application to application.
For an overview of various types of memory used by JVM I recommend this excellent answer: Java using much more memory than heap size (or size correctly Docker memory limit)

Finally, you can adjust the default allocation strategy (25% of available RAM) via -XX:MaxRAMPercentage flag - I typically set this to 60%, but for sure measure first!

Max Java Heap Memory allocation size - are there limits?

You can do it like that, but bear in mind allocating 100G from the launch of the application will make it launch slower, as it will attempt to allocate the full memory block at once.

Consider using a smaller value for the minimum heap size (Xms) so launch times are not impacted, as the VM will increment the size of the heap as required up to the value defined as maximum (Xmx) by itself.

How to configure the JVM heap memory size to be increased after jvm reached the maximum heap size set by the Xmx option

Try using -Xmx along with -Xms. Provide -Xms with the minimum required value (20GB) and -Xmx with the maximum possible value for your operating system.



Related Topics



Leave a reply



Submit