-XX参数:
jmap -heap pid 查看当前JVM使用的GC collector
查看当前JVM默认的配置参数
java -XX:+PrintFlagsFinal -version | grep :
java -XX:+PrintCommandLineFlags -version
查看GC的一些日志,详情另行查看。
把空间分成两块,每次只对其中一块进行 GC。当这块内存使用完时,就将还存活的对象复制到另一块上面
不同于针对新生代的复制算法,针对老年代的特点,创建该算法。主要是把存活对象移到内存的一端。
根据存活对象划分几块内存区,一般是分为新生代和老年代。然后根据各个年代的特点制定相应的回收算法。
标记 —— 清除
或者 标记 —— 整理
算法回收。 这是一个单线程收集器。意味着它只会使用一个CPU 或一条收集线程去完成收集工作,并且在进行垃圾回收时必须暂停其它所有的工作线程直到收集结束。
实际测试下来 young old eden survior的比例与设置的置并非强一致,差别较大。查看官方文档, 解释如下
The parallel collector is selected by default on server-class machines. In addition, the parallel collector uses a method of automatic tuning that allows you to specify specific behaviors instead of generation sizes and other low-level tuning details. You can specify maximum garbage collection pause time, throughput, and footprint (heap size).
-XX:MaxGCPauseMillis=
`<N> . This is interpreted as a hint that pause times of
<N>`milliseconds or less are desired; by default, there is no maximum pause time goal. If a pause time goal is specified, the heap size and other parameters related to garbage collection are adjusted in an attempt to keep garbage collection pauses shorter than the specified value. These adjustments may cause the garbage collector to reduce the overall throughput of the application, and the desired pause time goal cannot always be met. -XX:GCTimeRatio=
`<N> , which sets the ratio of garbage collection time to application time to
1 / (1 + <N>
)`.
For example, -XX:GCTimeRatio=19
sets a goal of 1/20 or 5% of the total time in garbage collection. The default value is 99, resulting in a goal of 1% of the time in garbage collection.
-Xmx
`<N>`. In addition, the collector has an implicit goal of minimizing the size of the heap as long as the other goals are being met. Priority of Goals
The goals are addressed in the following order:
The maximum pause time goal is met first. Only after it is met is the throughput goal addressed. Similarly, only after the first two goals have been met is the footprint goal considered.