gpt4 book ai didi

java - Metaspace 和 Native Area 内存是如何在 Java 中管理的?

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:00:43 25 4
gpt4 key购买 nike

据我了解,JVM 内的 Native Area 完全禁止垃圾收集器使用。 Metaspace 所在的 Native Area 内部。在前面提到的元空间中,我们有常量池、字段和方法数据等区域。

既然 Native Area 是由 C++ 内存管理管理的(或者至少我是这么理解的),为什么 Metaspace 不是固定大小,而是根据需要多少内存动态增长,会不会内存不足? Metaspace 是否允许垃圾收集器,但 Native Area 的其余部分不允许? C++ 是否在那里动态管理内存?

最佳答案

how come that Metaspace, that is not of a fixed size

您可以通过在命令行上设置 MaxMetaSpaceSize 的值来限制大小。

...will not run out of the memory?

是的,它确实耗尽了内存。当它超过可用内存的使用量时,将得到 java.lang.OutOfMemoryError: Metaspace 异常。

Is Garbage Collector allowed in the Metaspace

是的。 GC 将收集 Java 堆和元空间,但不收集 native 堆。它由拥有它的 native 代码的任何人管理。

引用:

3.2 Understand the OutOfMemoryError Exception

About G1 Garbage Collector, Permanent Generation and Metaspace

关于java - Metaspace 和 Native Area 内存是如何在 Java 中管理的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54277044/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com