Default max heap size

Ramki Ramakrishna y.s.ramakrishna at oracle.com
Mon Aug 29 23:40:04 PDT 2011


Hi Sergejs --

You are right. This seems to have been changed in hs16/6u18 via:-

*6887571 Increase default heap config sizes 
<http://monaco.sfbay.sun.com/detail.jsf?cr=6887571>

Changeset: *http://hg.openjdk.java.net/hsx/hsx16/baseline/rev/0799687b7385

The documentation you pointed to probably dates back to 6.0 FCS and is
likely obsolete in places. Unfortunately, I do not have a more up to date
counterpart of the document to point you to for the one place for 
consolidates
and more up to date information.

The release notes for 6u18 however did list this change here:-

http://www.oracle.com/technetwork/java/javase/6u18-142093.html

Search for "Server JVM heap configuration ergonomics".

-- ramki

On 8/29/2011 10:34 AM, Sergejs Melderis wrote:
> Hello.
> I am trying to figure out how the hotspot chooses the default maximum heap size.
> I posted this  question to stackoverflow, but got no answers.
> I don't want to repeat it here, so here is the question
> http://stackoverflow.com/questions/7194526/hotspot-default-max-heap-size
>
> I searched the jdk source code, for the place where it is calculated.
> I found function set_heap_size defined here
> http://hg.openjdk.java.net/jdk6/jdk6/hotspot/file/dc40301aed45/src/share/vm/runtime/arguments.cpp
>
> If am not wrong, the calculation happens in the following lines
>
> if (FLAG_IS_DEFAULT(MaxHeapSize)) {
>     julong reasonable_max = phys_mem / MaxRAMFraction;
>
>     if (phys_mem<= MaxHeapSize * MinRAMFraction) {
>       // Small physical memory, so use a minimum fraction of it for the heap
>       reasonable_max = phys_mem / MinRAMFraction;
>     } else {
>       // Not-small physical memory, so require a heap at least
>       // as large as MaxHeapSize
>       reasonable_max = MAX2(reasonable_max, (julong)MaxHeapSize);
>     }
>
>
> MaxRAMFraction is 4, so reasonable_max is phys_mem / 4. So, unless
> physical memory is very small,
> the reasonable_max will be MAX2(reasonable_max, (julong)MaxHeapSize);
>
> MAX2 is defined as
> #define MAX2(a, b) (((a)<  (b)) ? (b) : (a))
>
> At the end reasonable_max is set as MaxHeapSize
> FLAG_SET_ERGO(uintx, MaxHeapSize, (uintx)reasonable_max);
>
> If I plug in the memory size on my test machine, the reasonable_max
> will be very close to what I get from jmap -heap.
> With RAM of 8, 16 GB, or more, the MaxHeapSize will be greater than 1
> GB, which contradicts the documentation
> http://www.oracle.com/technetwork/java/javase/gc-tuning-6-140523.html#par_gc.ergonomics.default_size
>
> Thanks,
>
> Sergey.
> _______________________________________________
> hotspot-gc-use mailing list
> hotspot-gc-use at openjdk.java.net
> http://mail.openjdk.java.net/mailman/listinfo/hotspot-gc-use
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/hotspot-gc-dev/attachments/20110829/a1011386/attachment.html 
-------------- next part --------------
_______________________________________________
hotspot-gc-use mailing list
hotspot-gc-use at openjdk.java.net
http://mail.openjdk.java.net/mailman/listinfo/hotspot-gc-use


More information about the hotspot-gc-dev mailing list