0

Many of the recommendations are quite old. There has been several changes regarding Heap and GC in Java.

I have previously found recommendation that setting a too high max heap size could impact performance, making it worse. So could also setting a too low value.

Not setting max heap size will use system default, which is about 1/4 of its total memory. For my computer it will allocate 8GB to the JVM of my total memory.

I am using the Java 7 introduced G1GC with applying -XX:+UseG1GC during runtime.

It is very difficult to find a one size fits all for Max Heap Size. The application I am working on can be scaled from small to very large, depending on its composition (which is very dynamic and determined at runtime). I have seen some instances of the application not require more than 1GB of Max Heap, but others benefits from a larger size. Setting the Max Heap in Java Web Start to 4GB, or even 2GB causes problems with clients running 32bit (Java and/or OS, and yes those people do exist).

Is there actually any point setting Max Heap Size any more using either Java 7 or 8? The JVM will use what is available, and the GC will work between used heap and committed head. Or does the GC work between all used and max heap?

trincot
  • 317,000
  • 35
  • 244
  • 286
DJViking
  • 832
  • 1
  • 12
  • 29
  • You can see find some advice here. Click [http://stackoverflow.com/questions/1565388/increase-heap-size-in-java](http://stackoverflow.com/questions/1565388/increase-heap-size-in-java)! – MANITORATION Mar 21 '17 at 18:24
  • Not so much. Not quite the answers I am looking for on that link. I know how to set max heap, and I do know the theoretical limits for both 32bit and 64bit systems. Though I have experienced for some 32bit clients that 2048m wouldn't work even though 4g is the theoretical limit. I am looking for answers for recommended settings, and/or if setting max heap is any point any more. What the consequences are from wrong max heap. – DJViking Mar 21 '17 at 19:17

1 Answers1

0

Is there actually any point setting Max Heap Size any more using either Java 7 or 8?

If the JVM shares the OS with other applications that also need ram for example.

The JVM will use what is available, and the GC will work between used heap and committed head. Or does the GC work between all used and max heap?

Depending on configuration the GCs may or may not stay within a band of actual used heap. Under some circumstances they can dramatically inflate the heap size in an attempt to meet throughput or pause time goals. So constraining the heap provides more predictable heap sizes, possibly at the expense of throughput, latency or - if sized incorrectly - OOMs.

the8472
  • 40,999
  • 5
  • 70
  • 122