尽管 (Max)MetaspaceSize,Java 8 仍为 Metaspace 保留至少 1G

Java 8 reserves minimum 1G for Metaspace despite (Max)MetaspaceSize(尽管 (Max)MetaspaceSize,Java 8 仍为 Metaspace 保留至少 1G)

本文介绍了尽管 (Max)MetaspaceSize,Java 8 仍为 Metaspace 保留至少 1G的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java 8 刚启动后就为 Metaspace 保留 1G.这意味着最小元空间大小为 1G.但我将 MetaspaceSize 设置为 300m,MaxMetaspaceSize 设置为 400m.为什么 Java 的保留比我允许的多?

Java 8 reserves 1G for Metaspace just after it starts. It means that minimum metaspace size is 1G. But I set up MetaspaceSize to 300m and MaxMetaspaceSize to 400m. Why Java reserves more then I allow?

Java 版本

$ java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

虚拟机标志

$ jcmd 21689 VM.flags
21689:
-XX:CICompilerCount=3 -XX:ConcGCThreads=1 -XX:G1HeapRegionSize=1048576 -XX:InitialHeapSize=62914560 -XX:+ManagementServer -XX:MarkStackSize=4194304 -XX:MaxHeapSize=1006632960 -XX:MaxMetaspaceSize=399998976 -XX:MaxNewSize=603979776 -XX:MetaspaceSize=299999232 -XX:MinHeapDeltaBytes=1048576 -XX:NativeMemoryTracking=summary -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseFastUnorderedTimeStamps -XX:+UseG1GC 

神经机器翻译

[jetty9-proxy@bm01 bin]$ jcmd 21689 VM.native_memory
21689:

Native Memory Tracking:

Total: reserved=2769543KB, committed=1311159KB

-                     Class (reserved=1221904KB, committed=197904KB)
                            (classes #36543)
                            (malloc=3344KB #44041) 
                            (mmap: reserved=1218560KB, committed=194560KB) 

刚开始就是

Total: reserved=2402748KB, committed=150796KB     

-                     Class (reserved=1056956KB, committed=7868KB)
                            (classes #1300)
                            (malloc=188KB #564) 
                            (mmap: reserved=1056768KB, committed=7680KB) 

推荐答案

Java 为 Classes 保留 1G 的原因隐藏在它管理压缩类指针的方式上.

The reason why Java reserves 1G for Classes hides in the way how it manages compressed class pointers.

长答案:阅读此文档 https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/considerations.html

简短回答:在 'CompressedClassSpaceSize' 属性 -XX:CompressedClassSpaceSize=300m 中设置正确的大小

The short answer: setup the correct size in 'CompressedClassSpaceSize' property -XX:CompressedClassSpaceSize=300m

这篇关于尽管 (Max)MetaspaceSize,Java 8 仍为 Metaspace 保留至少 1G的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:尽管 (Max)MetaspaceSize,Java 8 仍为 Metaspace 保留至少 1G

基础教程推荐