PSYoungGen不是"eden","from"的总和.和“到"? [英] PSYoungGen is not the sum of "eden", "from" and "to"?

查看:110
本文介绍了PSYoungGen不是"eden","from"的总和.和“到"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的演示来检查JVM内存分配的详细信息.释放.

I have a simple demo to check the details of JVM memory allocation & deallocation.

Java版本

$ java -version
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)

演示

/**
 * VM Options: -Xms20M -Xmx20M -Xmn10M -XX:+PrintGCDetails -XX:SurvivorRatio=8
 */
public class DefaultCollector {
    private static final int _1MB = 1024 * 1024;
    public static void main(String... args) {
        byte[] arr1 = new byte[2 * _1MB];
        byte[] arr2 = new byte[2 * _1MB];
        byte[] arr3 = new byte[2 * _1MB];
        byte[] arr4 = new byte[4 * _1MB];
    }
}

手动使用CLI来编译和运行程序,

I manually used the CLI to compile and run the program as

$ javac DefaultCollector.java 
$ java -Xms20M -Xmx20M -Xmn10M -XX:+PrintGCDetails -XX:SurvivorRatio=8 DefaultCollector

GC日志

Heap
 PSYoungGen      total 9216K, used 6979K [0x00000000ff600000, 0x0000000100000000, 0x0000000100000000)
  eden space 8192K, 85% used [0x00000000ff600000,0x00000000ffcd0f68,0x00000000ffe00000)
  from space 1024K, 0% used [0x00000000fff00000,0x00000000fff00000,0x0000000100000000)
  to   space 1024K, 0% used [0x00000000ffe00000,0x00000000ffe00000,0x00000000fff00000)
 ParOldGen       total 10240K, used 4096K [0x00000000fec00000, 0x00000000ff600000, 0x00000000ff600000)
  object space 10240K, 40% used [0x00000000fec00000,0x00000000ff000010,0x00000000ff600000)
 Metaspace       used 2468K, capacity 4486K, committed 4864K, reserved 1056768K
  class space    used 265K, capacity 386K, committed 512K, reserved 1048576K

我的问题

  1. -Xms20M -Xmx20M -Xmn10M -XX:SurvivorRatio = 8 已设置,并且 eden:8M,从:1M,到:1M 清晰呈现,为什么 PSYoungGen 总计9216K 而不是 10240K ?
  2. 为什么 元空间 占用大量内存 Metaspace使用了2468K ?里面到底有什么?是否有仅类型信息?
  1. -Xms20M -Xmx20M -Xmn10M -XX:SurvivorRatio=8 already set and eden: 8M, from: 1M, and to: 1M presented clearly, why PSYoungGen total 9216K instead of 10240K?
  2. why Metaspace taking so much memory Metaspace used 2468K? what's in there exactly? Are there only type information?

推荐答案

对于第一个问题,@ Holger提供了非常直接的实验来演示

As for the first question, @Holger has provided quite direct experiment to demonstrate the fact.

报告给年轻一代"的总大小始终仅包含eden和来自空间的内容,忽略了始终为空的 to 空间,这与后面报告的地址不一致大小,其中包括完整的跨度,覆盖了所有三个空间.

The total size reported for the Young Generation always includes the eden and from space only, ignoring the always-empty to space, which is inconsistent to the addresses reported behind the sizes, which include the complete span, covering all three spaces.

然后是第二个

为什么Metaspace占用大量内存Metaspace使用2468K?里面到底有什么?只有类型信息吗?

why Metaspace taking so much memory Metaspace used 2468K? what's in there exactly? Are there only type information?

我在中找到了它的规范Java平台标准版HotSpot虚拟机垃圾收集调优指南 as

在以Metaspace开头的行中,已用值是用于加载的类的空间量...以类空格行开头的行包含的元数据的相应值压缩的类指针.

In the line beginning with Metaspace, the used value is the amount of space used for loaded classes...The line beginning with class space line contains the corresponding values for the metadata for compressed class pointers.

这篇关于PSYoungGen不是"eden","from"的总和.和“到"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆