Jon Masamitsu's Weblog

  • Java
    February 12, 2007

How Does Your Garden Grow?

Guest Author
Actually, the title should be "How Does Your Generation Grow"
but then the literary reference would have been totally lost.

I've written about how the generations grow if you are using
GC ergonomics.


What if you're not using GC ergonomics? There is a different
policy for growing and shrinking the heap that is used
by the low pause collector and the serial collector. If
you're interested in that policy, this is you're lucky

It's actually pretty straightforward. At the end of the collection
of a generation, we check the amount of free space in the generation.
If the amount of free space is below a certain percentage (specified by
MinHeapFreeRatio) of the total size of the generation, then the
generation is expanded. Basically, we ask if we have enough
free space in the generation so that the VM can run a while
before we have to collect again. At the other end we don't want to have
an excessive amount of free space so if the amount of free space is above a
certain percentage (specified by MaxHeapFreeRatio) the generation
is shrunk. That's it.

If you decide to play with the free ratio parameters,
leave enough distance between MinHeapFreeRatio and MaxHeapFreeRatio
so that the generations are not constantly adjusting
by small amounts to get to the "perfect" ratio. Also our
experience is that even if a generation does not need the
extra free space right now, it will shortly, so don't be too
aggressive with MaxHeapFreeRatio.

Will this policy eventually be replaced by GC ergonomics? Actually,
I think not. I recently talked to a customer who told me that
he was more concerned with bounds on the heap footprint than with
achieving some specific throughput. The way he put it was something
like "I don't want to be doing GC's all the time so there should be
a good amount of free space in the heap but not too much".
This policy is one approximation of what he wants.

Join the discussion

Comments ( 3 )
  • Parwinder Sekhon Tuesday, February 13, 2007
    Do the survivor spaces in Eden ever get dynamically resized too?
  • Damon Hart-Davis Tuesday, February 13, 2007
    That would be good if the system could detect excessively high (or low) young-gen turnover for example... I never want to have to guess that myself as app installer!



  • Jon Usmastami Friday, February 23, 2007

    Yes, the survivor spaces are dynamically resized. If not using GC ergonomics, the SurvivorRatio is used to calculate the new size of the survivor spaces based on the new size of the young generation.


    I'm no sure what you mean by "turnover" in the young generation. If you're referring to the amount of promotion out of the young generation, without GC ergonomics the promotion rate is controlled by the tenuring threshold and that does not dynamically adjust. With GC ergonomics, it does dynamically adjust.

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.