ANT_OPTS -Xmx1024m 不起作用
我将环境中的 ANT_OPTS 设置为“-Xms256m -Xmx1024m”。设置此后,我无法从命令提示符运行 ant 文件。它向我抛出一个错误:
“VM 初始化期间发生错误 无法为对象堆保留足够的空间 无法创建 Java 虚拟机。”
虽然我有足够的可用物理内存(超过 2048m 可用)来为 ANT_OPTS 分配 1024m,但它仍然抛出上述错误。是否还有其他原因导致我无法将 Xmx 设置为 1024m ?
I am setting ANT_OPTS in the environment to "-Xms256m -Xmx1024m". After setting this, I am not able to run ant files from command prompt. It throws me an error of:
"Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine."
Although I have enough physical memory available (more than 2048m available) to allot 1024m for ANT_OPTS, but still it throws the above error. Can there be any other reason why I cannot set Xmx to 1024m ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
无论如何,以下是解决方法:
转到开始->控制面板->系统->高级(选项卡)->环境变量->系统变量->新建:
或
或
更改 ant 调用,如下所示。
然后使用 ant 再次构建文件。
这对我有用。
Anyway, here is how to fix it:
Go to Start->Control Panel->System->Advanced(tab)->Environment Variables->System Variables->New:
or
or
Change the ant call as shown as below.
then build the files again using the ant.
It worked for me.
您没有提及您正在运行的操作系统。如果您使用的是 Windows(尤其是 32 位),我经常会看到分配超过 800MB 作为堆的问题,无论您有多少实际可用内存。这并不是真正的 Windows 攻击:Windows JVM 希望在连续的块中分配其所有堆,如果不能,它将无法启动。
我认为Windows XP上的Java最大内存很好地解释了这个问题以及你如何尝试解决它。
You don't mention what OS you're running. If you're on Windows (especially 32-bit) I often see problems allocating more than, say, 800MB as heap, regardless of how much actual memory you have available. This isn't really Windows bashing: the Windows JVM wants to allocate all of its heap in a contiguous chunk and if it can't it fails to start.
I think Java maximum memory on Windows XP does a good job of explaining the problem and how you might try to solve it.
无论你最初设置的最小堆是什么,JVM都会在启动时尝试分配。在你的机器(我假设是32位机器)中,JVM似乎无法分配并且JVM启动失败。尝试将
-Xms
设置为128
或更小。它应该有效。What ever you set initially as minimum heap, the JVM will try to allocate at start up.It seems in your machine (32 bit machine I assume) the JVM is unable to allocate and JVM start up fails. Try setting
-Xms
to128
or less. It should work.