Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java garbage collection

 
luri ron
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
while tuning the gc parameter, why do we sometimes want to allow object to age more in the young generation before the objects are moved the old generation? is it because the young generation collector perform better than the old generation collector? or is it more expensive to move the memory from young generation to old generation during gc? thanks.
 
Peter Johnson
author
Bartender
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Major collection typically take longer than minor collections, therefore you want to delay moving objects to the tenured generation as long as possible. By having a high tenuring threshold, there is a greater chance that an object will go out of scope and become unused and be cleaned up by a minor collection.

Of course, if you have objects that expect to survive a long time, then you would really want to move them to the tenured generation as soon as possible. But analysis of heap object has shown that short lived objects vastly outnumber long lived objects, so the preference is to have a high tenuring threshold.

See also: http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html, especially the graph on object lifetimes.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic