我有一个Netty进程,使用带有4个线程的并行GC,运行着8 GB的堆。我正在尝试分析堆,并观察到jmap中显示的所有容量的总和甚至不接近8 GB,Old Gen仅1.5 GB,Young Gen 750 MB。以下是jmap -heap 7595的输出Attaching to process ID 7595, please wait...Debugger attached successfully.Server compiler detected.JVM version is 25.131-b11using thread-local object allocation.Parallel GC with 4 thread(s)Heap Configuration: MinHeapFreeRatio = 30 MaxHeapFreeRatio = 70 MaxHeapSize = 8589934592 (8192.0MB) NewSize = 88080384 (84.0MB) MaxNewSize = 2863136768 (2730.5MB) OldSize = 176160768 (168.0MB) NewRatio = 2 SurvivorRatio = 8 MetaspaceSize = 21807104 (20.796875MB) CompressedClassSpaceSize = 1073741824 (1024.0MB) MaxMetaspaceSize = 17592186044415 MB G1HeapRegionSize = 0 (0.0MB)Heap Usage:PS Young GenerationEden Space: capacity = 763363328 (728.0MB) used = 418551600 (399.1619110107422MB) free = 344811728 (328.8380889892578MB) 54.8299328311459% usedFrom Space: capacity = 1048576 (1.0MB) used = 458752 (0.4375MB) free = 589824 (0.5625MB) 43.75% usedTo Space: capacity = 1048576 (1.0MB) used = 0 (0.0MB) free = 1048576 (1.0MB) 0.0% usedPS Old Generation capacity = 1530396672 (1459.5MB) used = 1196099760 (1140.6896209716797MB) free = 334296912 (318.8103790283203MB) 78.15619191309898% used27146 interned Strings occupying 3164408 bytes.[年轻一代容量(728)+老一代容量(1459)= 2187 MB] (adsbygoogle = window.adsbygoogle || []).push({}); 最佳答案 默认情况下,JVM在启动后不会分配最大堆,而是在JVM需要时分配并扩展较小的初始堆。您可以使用-Xms标志将初始堆大小强制为8GB,例如-Xms8g按照docs: -Xmssize 设置堆的初始大小(以字节为单位)。此值必须是1024的倍数且大于1 MB。字母k或K表示千字节,m或M表示兆字节,g或G表示千兆字节。 (adsbygoogle = window.adsbygoogle || []).push({}); 09-30 09:57