java main 加大内存_当jvm可以设置一个最大内存时,jvm是否可以增加最大内存?

是的,有一个最大值,但这取决于系统。试试看,翻一番,直到达到极限,然后向下搜索。至少对于linux上的Sun JRE 1.6,您会发现有趣的错误消息(peregrino是运行32位ubuntu的上网本,2G RAM,无交换):

peregrino:$ java -Xmx4096M -cp bin WheelPrimes

Invalid maximum heap size: -Xmx4096M

The specified size exceeds the maximum representable size.

Could not create the Java virtual machine.

peregrino:$ java -Xmx4095M -cp bin WheelPrimes

Error occurred during initialization of VM

Incompatible minimum and maximum heap sizes specified

peregrino:$ java -Xmx4092M -cp bin WheelPrimes

Error occurred during initialization of VM

The size of the object heap + VM data exceeds the maximum representable size

peregrino:$ java -Xmx4000M -cp bin WheelPrimes

Error occurred during initialization of VM

Could not reserve enough space for object heap

Could not create the Java virtual machine.

(experiment reducing from 4000M until)

peregrino:$ java -Xmx2686M -cp bin WheelPrimes

(normal execution)

大多数都是不言而喻的,除了-Xmx4095M,它相当奇怪(可能是有符号/无符号比较?),并声称在一台2GB的机器上预留26.86亿美元,无需交换。但这也暗示了32位虚拟机的最大大小是4G,而不是2G,如果操作系统允许你处理那么多。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值