-XX:+PrintTenuringDistribution 不打印每个年龄段的尺寸

-XX:+PrintTenuringDistribution doesn't print size per age

我编写了一个简单的程序,它无限地将对象添加到集合中,我想查看 PrintTenuringDistribution 选项的标准输出:

public static void main(String[] args) {
    while (true) {
        persons.add(new Person("jorik", "kornev"));
    }
}

作为程序输出,我得到:

Desired survivor size 5242880 bytes, new threshold 7 (max 15)

Desired survivor size 5242880 bytes, new threshold 7 (max 15)

Desired survivor size 5242880 bytes, new threshold 7 (max 15)

实际上我建议我会得到这样的东西:

Desired survivor size 75497472 bytes, new threshold 15 (max 15)
- age   1:   19321624 bytes,   19321624 total
- age   2:      79376 bytes,   19401000 total
- age   3:    2904256 bytes,   22305256 total

我正在使用 JDK 1.7.0_79 和 VM 选项:

-XX:+PrintTenuringDistribution -XX:+UseParallelGC

所以,请问我做错了什么以及如何获得所需的输出。

谢谢,Evgeniy

根据 this blog post 它正在按预期工作。

Well, this is the expected behavior and is not a bug. Throughput collector does not use the age table like the other collectors do. And due to that reason, the age histogram information is not printed with the throughput collector. With the throughput collector, we can only see the desired survivor size, threshold age, and the maximum threshold age with PrintTenuringDistribution option.