Java垃圾回收——设置内存大小

本文介绍了Java虚拟机(JVM)堆的初始化过程及其空间管理方式。通过-Xmx和-Xms参数可以设置最大和初始堆空间。当-Xms小于-Xmx时,并非所有空间立即分配给JVM,未分配的空间标记为虚拟。随着永久代、老年代及新生代的需求增长,这些区域会扩展至虚拟空间限制。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 At initialization of the virtual machine, the entire space for the heap is reserved. The size of the space reserved can be specified with the -Xmx option.
If the value of the -Xms parameter is smaller than the value of the -Xmx parameter, not all of the space that is reserved is immediately committed to the virtual machine.
The uncommitted space is labeled "virtual" in this figure. The different parts of the heap (permanent generation, tenured generation, and young generation) can grow to the limit of the virtual space as needed.

其中内部各部分的大小也可以设置。

一般建议固定大小,不要让虚拟机在调整大小上浪费性能。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值