The discussion forums in the XSEDE User Portal are for users to share experiences, questions, and comments with other users and XSEDE staff. Visitors are welcome to browse and search, but you must login to contribute to the forums. While XSEDE staff monitor the lists, XSEDE does not guarantee that questions will be answered. Please note that the forums are not a replacement for formal support or bug reporting procedures through the XSEDE Help Desk. You must be logged in to post to the user forums.

« Back

java heap size error

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
java heap size error
Answer
2/14/16 2:47 AM
Dear forum users,

On using the java -Xmx1200m comand to run a jar file, or using the build.sh to compile to a target jar file I got the error:
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.

I tried reducing the heap with the flag -mx128m or -Xmx64m to no avail.

Any idea what is happening and how would I get over this error? Many Thanks! -Victor

BTW if I omit the -mx128m flag I had this version error for java (I posted this question posted a week ago https://www.xsede.org/group/xup/forums/-/message_boards/message/1142488):
Exception in thread "main" java.lang.UnsupportedClassVersionError: edu/cmu/ark/QuestionAsker : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)

RE: java heap size error
Answer
3/21/19 10:13 AM as a reply to Victor Shum.
There is not enough virtual memory space requested by an application thus the application fails to start. This usually happens during the application startup phase. Applications reserve a large amount of virtual memory for the JVM heap space during the startup phase. Java on Windows uses an initial size of 16 Megabyte and a maximum of 64 Megabyte.

Most of the time you can fix this problem by uninstalling the Java runtime and then reinstalling it all over again. You can also try increasing the amount of system memory allocated to the Java virtual machine by setting an environment variable.

Open the Control Panel
Go to System
Go to Advanced Systems Properties
Then Environment Variables
In System Variables, click Add
New Variable Name: _JAVA_OPTIONS
New Variable Value: -Xmx512M
Click OK