当尝试增加jvm内存时,是否有最大数量可以设置Xmx? [英] Is there a maximum number you can set Xmx to when trying to increase jvm memory?

查看:458
本文介绍了当尝试增加jvm内存时,是否有最大数量可以设置Xmx?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有最大你可以设置Xmx的大小?我把它设置为1024m,eclipse打开了。当我设置它高于1024时,eclipse不会打开,我得到错误jvm terminated。退出代码= -1...



我这样做是因为我不断得到一个java.lang.OutOfMemoryError:Java堆空间。我在一个35.5Mb .txt文件中读取,当它只是使用$ code> while((= line = reader.readLine())!= null)

解决方案

是的,有一个最大值,但它是系统依赖的。尝试看看,加倍,直到你达到极限,然后搜索下来。至少对于linux上的Sun JRE 1.6,如果不是总是有意义的错误消息(peregrino是上网本运行32位ubuntu与2G RAM并且没有互换),您将获得有趣的消息:

  peregrino:$ java -Xmx4096M -cp bin WheelPrimes 
无效的最大堆大小:-Xmx4096M
指定的大小超过最大可表示的大小。
无法创建Java虚拟机。

peregrino:$ java -Xmx4095M -cp bin WheelPrimes
VM初始化期间发生错误
指定的最小和最大堆大小不兼容

peregrino:$ java -Xmx4092M -cp bin WheelPrimes
VM初始化期间发生错误
对象堆+ VM数据的大小超过最大可表示大小

peregrino:$ java -Xmx4000M - cp bin WheelPrimes
VM初始化期间发生错误
无法为对象堆保留足够的空间
无法创建Java虚拟机。

(从4000M直到实验减少)

peregrino:$ java -Xmx2686M -cp bin WheelPrimes
(正常执行)

除了-Xmx4095M以外,大部分都是自我解释的(可能是签名/无符号比较?),而且它声称保留2686M一个2GB的机器,没有互换。但是它提示,如果操作系统允许您解决这个问题,最大大小为4G,而不是2G的32位虚拟机。


Is there a max. size you can set Xmx to? I set it to 1024m and eclipse opens ok. When I set it above 1024, eclipse doesn't open and I get the error "jvm terminated. Exit code=-1"...

I was doing this because I keep getting an "java.lang.OutOfMemoryError: Java heap space". I am reading in a 35.5Mb .txt file and this error occurs when it's just reading in the file using the "while((line = reader.readLine()) != null)" loop. I would have thought that 1024mb would have been enough. Can anyone help me?

解决方案

Yes, there is a maximum, but it's system dependent. Try it and see, doubling until you hit a limit then searching down. At least with Sun JRE 1.6 on linux you get interesting if not always informative error messages (peregrino is netbook running 32 bit ubuntu with 2G RAM and no swap):

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)

Most are self explanatory, except -Xmx4095M which is rather odd (maybe a signed/unsigned comparison?), and that it claims to reserve 2686M on a 2GB machine with no swap. But it does hint that the maximum size is 4G not 2G for a 32 bit VM, if the OS allows you to address that much.

这篇关于当尝试增加jvm内存时,是否有最大数量可以设置Xmx?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆