src/share/vm/memory/collectorPolicy.cpp

Print this page




 429     // Bound the maximum size by NewSize below (since it historically
 430     // would have been NewSize and because the NewRatio calculation could
 431     // yield a size that is too small) and bound it by MaxNewSize above.
 432     // Ergonomics plays here by previously calculating the desired
 433     // NewSize and MaxNewSize.
 434     max_new_size = MIN2(MAX2(max_new_size, NewSize), MaxNewSize);
 435   }
 436   assert(max_new_size > 0, "All paths should set max_new_size");
 437 
 438   // Given the maximum gen0 size, determine the initial and
 439   // minimum gen0 sizes.
 440 
 441   if (_max_heap_byte_size == _min_heap_byte_size) {
 442     // The maximum and minimum heap sizes are the same so the generations
 443     // minimum and initial must be the same as its maximum.
 444     _min_gen0_size = max_new_size;
 445     _initial_gen0_size = max_new_size;
 446     _max_gen0_size = max_new_size;
 447   } else {
 448     size_t desired_new_size = 0;
 449     if (!FLAG_IS_DEFAULT(NewSize)) {
 450       // If NewSize is set ergonomically (for example by cms), it
 451       // would make sense to use it.  If it is used, also use it
 452       // to set the initial size.  Although there is no reason
 453       // the minimum size and the initial size have to be the same,
 454       // the current implementation gets into trouble during the calculation
 455       // of the tenured generation sizes if they are different.
 456       // Note that this makes the initial size and the minimum size
 457       // generally small compared to the NewRatio calculation.
 458       _min_gen0_size = NewSize;
 459       desired_new_size = NewSize;







 460       max_new_size = MAX2(max_new_size, NewSize);
 461     } else {
 462       // For the case where NewSize is the default, use NewRatio
 463       // to size the minimum and initial generation sizes.
 464       // Use the default NewSize as the floor for these values.  If
 465       // NewRatio is overly large, the resulting sizes can be too small.
 466       _min_gen0_size = MAX2(scale_by_NewRatio_aligned(_min_heap_byte_size), NewSize);
 467       desired_new_size =
 468         MAX2(scale_by_NewRatio_aligned(_initial_heap_byte_size), NewSize);
 469     }
 470 
 471     assert(_min_gen0_size > 0, "Sanity check");
 472     _initial_gen0_size = desired_new_size;
 473     _max_gen0_size = max_new_size;
 474 
 475     // At this point the desirable initial and minimum sizes have been
 476     // determined without regard to the maximum sizes.
 477 
 478     // Bound the sizes by the corresponding overall heap sizes.
 479     _min_gen0_size = bound_minus_alignment(_min_gen0_size, _min_heap_byte_size);




 429     // Bound the maximum size by NewSize below (since it historically
 430     // would have been NewSize and because the NewRatio calculation could
 431     // yield a size that is too small) and bound it by MaxNewSize above.
 432     // Ergonomics plays here by previously calculating the desired
 433     // NewSize and MaxNewSize.
 434     max_new_size = MIN2(MAX2(max_new_size, NewSize), MaxNewSize);
 435   }
 436   assert(max_new_size > 0, "All paths should set max_new_size");
 437 
 438   // Given the maximum gen0 size, determine the initial and
 439   // minimum gen0 sizes.
 440 
 441   if (_max_heap_byte_size == _min_heap_byte_size) {
 442     // The maximum and minimum heap sizes are the same so the generations
 443     // minimum and initial must be the same as its maximum.
 444     _min_gen0_size = max_new_size;
 445     _initial_gen0_size = max_new_size;
 446     _max_gen0_size = max_new_size;
 447   } else {
 448     size_t desired_new_size = 0;
 449     if (FLAG_IS_CMDLINE(NewSize)) {
 450       // If NewSize is set on the command line, we must use it as
 451       // the initial size and it also makes sense to use it as the
 452       // lower limit.





 453       _min_gen0_size = NewSize;
 454       desired_new_size = NewSize;
 455       max_new_size = MAX2(max_new_size, NewSize);
 456     } else if (FLAG_IS_ERGO(NewSize)) {
 457       // If NewSize is set ergonomically, we should use it as a lower
 458       // limit, but use NewRatio to calculate the initial size.
 459       _min_gen0_size = NewSize;
 460       desired_new_size =
 461         MAX2(scale_by_NewRatio_aligned(_initial_heap_byte_size), NewSize);
 462       max_new_size = MAX2(max_new_size, NewSize);
 463     } else {
 464       // For the case where NewSize is the default, use NewRatio
 465       // to size the minimum and initial generation sizes.
 466       // Use the default NewSize as the floor for these values.  If
 467       // NewRatio is overly large, the resulting sizes can be too small.
 468       _min_gen0_size = MAX2(scale_by_NewRatio_aligned(_min_heap_byte_size), NewSize);
 469       desired_new_size =
 470         MAX2(scale_by_NewRatio_aligned(_initial_heap_byte_size), NewSize);
 471     }
 472 
 473     assert(_min_gen0_size > 0, "Sanity check");
 474     _initial_gen0_size = desired_new_size;
 475     _max_gen0_size = max_new_size;
 476 
 477     // At this point the desirable initial and minimum sizes have been
 478     // determined without regard to the maximum sizes.
 479 
 480     // Bound the sizes by the corresponding overall heap sizes.
 481     _min_gen0_size = bound_minus_alignment(_min_gen0_size, _min_heap_byte_size);