Could not reserve enough space for object heap
When I am running I am getting the following exception repeatedly each time I try to run the program.
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
I tried to increase my virtual memory (page size) and RAM size, but to no avail. Can anyone tell me how can I eliminate this error?
使用-XX:MaxHeapSize=512m
(或任何大数字)(或简称为-Xmx512m
)运行JVM,
This can also be caused by setting something too large on a 32-bit HotSpot vm, for example:
-Xms1536m -Xmx1536m
where this might/would work:
-Xms1336m -Xmx1336m
I ran into this when using javac, and it doesn't seem to pick up on the command line options,
-bash-3.2$ javac -Xmx256M HelloWorldApp.java
Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
so the solution here it so set _JAVA_OPTIONS
-bash-3.2$ export _JAVA_OPTIONS="-Xmx256M"
-bash-3.2$ javac HelloWorldApp.java
Picked up _JAVA_OPTIONS: -Xmx256M
And this compiles fine.
This happens to me on machines with a lot of ram, but with lower memory ulimits. Java decides to allocate a big heap because it detects the ram in the machine, but it's not allowed to allocate it because of ulimits.
链接地址: http://www.djcxy.com/p/2352.html上一篇: 类成员和显式堆栈/堆分配
下一篇: 无法为对象堆预留足够的空间