Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does invoking System.gc() in java suggest garbage collection of the tenured generation as well as the young generation?

When invoking System.gc() in java (via JMX), it will dutifully (attempt to) clean the young generation. This generally works very well. I have never seen it attempt to clean the tenured generation, though. This leads me to two questions:

  1. Can the tenured generation even be collected (i.e. is there actually garbage in this generation, or do all objects in the tenured generation actually still have live references to them)?
  2. If the tenured generation can be collected, can this be done via System.gc(), or is there another way to do it (unlikely), or will I simply have to wait until I run out of space in the tenured generation?
like image 756
Markus Jevring Avatar asked May 20 '10 08:05

Markus Jevring


1 Answers

http://java.sun.com/javase/technologies/hotspot/gc/gc_tuning_6.html#other_considerations states that System.gc() triggers a major collection, i.e. including tenured.

Have you seen this not to be the case in the GC logs?

like image 163
JoseK Avatar answered Oct 07 '22 13:10

JoseK