首页 新闻 搜索 专区 学院

请问java程序为什么设置了JVM参数 -Xmx为2650m。但是实际使用内存还是会达到3.5G呢?

0
悬赏园豆:30 [待解决问题]

我限制了Xmx为2650,但是为啥超了1个G?请大佬帮忙指导

以下是参数:
jdk1.8 sentos7

jps -v
6624 server-0.0.1-SNAPSHOT.jar -Xms2350m -Xmx2650m -Xmn2000m

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
6624 root 20 0 10.2g 3.5g 11476 S 53.3 45.9 3813:06 java

jmap -heap 6624

Attaching to process ID 6624, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.172-b11

using thread-local object allocation.
Parallel GC with 4 thread(s)

Heap Configuration:
MinHeapFreeRatio = 0
MaxHeapFreeRatio = 100
MaxHeapSize = 2778726400 (2650.0MB)
NewSize = 2097152000 (2000.0MB)
MaxNewSize = 2097152000 (2000.0MB)
OldSize = 367001600 (350.0MB)
NewRatio = 2
SurvivorRatio = 8
MetaspaceSize = 21807104 (20.796875MB)
CompressedClassSpaceSize = 1073741824 (1024.0MB)
MaxMetaspaceSize = 17592186044415 MB
G1HeapRegionSize = 0 (0.0MB)

Heap Usage:
PS Young Generation
Eden Space:
capacity = 2070413312 (1974.5MB)
used = 462973016 (441.52547454833984MB)
free = 1607440296 (1532.9745254516602MB)
22.361381339495562% used
From Space:
capacity = 13631488 (13.0MB)
used = 4538384 (4.3281402587890625MB)
free = 9093104 (8.671859741210938MB)
33.29338660606971% used
To Space:
capacity = 13107200 (12.5MB)
used = 0 (0.0MB)
free = 13107200 (12.5MB)
0.0% used
PS Old Generation
capacity = 681574400 (650.0MB)
used = 660437112 (629.841911315918MB)
free = 21137288 (20.15808868408203MB)
96.8987555870643% used

jcmd 6624 GC.heap_info
6624:
6624:
PSYoungGen total 2034688K, used 1245117K [0x0000000743000000, 0x00000007c0000000, 0x00000007c0000000)
eden space 2021888K, 61% used [0x0000000743000000,0x000000078ec2b420,0x00000007be680000)
from space 12800K, 30% used [0x00000007be680000,0x00000007bea44010,0x00000007bf300000)
to space 12800K, 0% used [0x00000007bf380000,0x00000007bf380000,0x00000007c0000000)
ParOldGen total 665600K, used 654323K [0x000000071a600000, 0x0000000743000000, 0x0000000743000000)
object space 665600K, 98% used [0x000000071a600000,0x00000007424fcf88,0x0000000743000000)
Metaspace used 79265K, capacity 85640K, committed 86016K, reserved 1124352K
class space used 9454K, capacity 10410K, committed 10496K, reserved 1048576K

坚守信念的主页 坚守信念 | 初学一级 | 园豆:168
提问于:2020-01-28 15:51
< >
分享
所有回答(1)
0

-Xmx2650m 只是设定了jvm运行时最大可分配的堆空间大小为2560m,jvm本身、栈空间、本地方法区等同样需要操作系统分配内存

乱极而止 | 园豆:202 (菜鸟二级) | 2020-01-29 08:45

那些东西那么大吗?不是应该一两百兆就够了吗? 刚启动的时候是2.7G 然后慢慢的多 昨天多到3.1G,今天我看了一眼,变成3.2G了。半个G还要多

支持(0) 反对(0) 坚守信念 | 园豆:168 (初学一级) | 2020-01-29 09:07

项目中大量使用框架,大量的反射和动态代理创建的代理类,然后你懂的……

支持(0) 反对(0) 旧城已空旧梦已逝 | 园豆:212 (菜鸟二级) | 2020-01-29 11:57

@旧城已空旧梦已逝: 那 现在都3.3G了,请问那些多出来的是存到这里了吗?CompressedClassSpaceSize

最新的:
jmap -heap 6624
Attaching to process ID 6624, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.172-b11

using thread-local object allocation.
Parallel GC with 4 thread(s)

Heap Configuration:
MinHeapFreeRatio = 0
MaxHeapFreeRatio = 100
MaxHeapSize = 2778726400 (2650.0MB)
NewSize = 2097152000 (2000.0MB)
MaxNewSize = 2097152000 (2000.0MB)
OldSize = 367001600 (350.0MB)
NewRatio = 2
SurvivorRatio = 8
MetaspaceSize = 21807104 (20.796875MB)
CompressedClassSpaceSize = 1073741824 (1024.0MB)
MaxMetaspaceSize = 17592186044415 MB
G1HeapRegionSize = 0 (0.0MB)

Heap Usage:
PS Young Generation
Eden Space:
capacity = 2037383168 (1943.0MB)
used = 1717763376 (1638.1868133544922MB)
free = 319619792 (304.8131866455078MB)
84.31223949328319% used
From Space:
capacity = 29360128 (28.0MB)
used = 4921672 (4.693672180175781MB)
free = 24438456 (23.30632781982422MB)
16.76311492919922% used
To Space:
capacity = 28311552 (27.0MB)
used = 0 (0.0MB)
free = 28311552 (27.0MB)
0.0% used
PS Old Generation
capacity = 681574400 (650.0MB)
used = 637472712 (607.9413528442383MB)
free = 44101688 (42.05864715576172MB)
93.52943889911359% used

支持(0) 反对(0) 坚守信念 | 园豆:168 (初学一级) | 2020-01-30 11:39

@旧城已空旧梦已逝:
jcmd 6624 GC.heap_info
6624:
PSYoungGen total 2016768K, used 1243923K [0x0000000743000000, 0x00000007c0000000, 0x00000007c0000000)
eden space 1986560K, 62% used [0x0000000743000000,0x000000078eaf8fd8,0x00000007bc400000)
from space 30208K, 12% used [0x00000007bc400000,0x00000007bc7cc010,0x00000007be180000)
to space 28672K, 0% used [0x00000007be400000,0x00000007be400000,0x00000007c0000000)
ParOldGen total 665600K, used 611501K [0x000000071a600000, 0x0000000743000000, 0x0000000743000000)
object space 665600K, 91% used [0x000000071a600000,0x000000073fb2b7e0,0x0000000743000000)
Metaspace used 78192K, capacity 84560K, committed 84608K, reserved 1124352K
class space used 9387K, capacity 10360K, committed 10368K, reserved 1048576K

支持(0) 反对(0) 坚守信念 | 园豆:168 (初学一级) | 2020-01-30 11:43

@旧城已空旧梦已逝: Metaspace和 class space 看着也不高

支持(0) 反对(0) 坚守信念 | 园豆:168 (初学一级) | 2020-01-30 11:47
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册