Reserving space for a heap object

0 votes

I was trying to increase the virtual memory and RAM size in my 32-bit cmd shell. But each time I am executing the program, I am getting the below exception:

Error occurred during initialization of VM

Could not reserve enough space for object heap

Could not create the Java virtual machine

Please help me out in eliminating this exception.

May 31, 2018 in Java by v.liyyah
• 1,300 points
108 views

1 answer to this question.

0 votes

I too encountered this problem and tried resolving it through the command line. But it seems like it doesn’t understand the cmd 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.

I think here you will have to set the _JAVA_OPTIONS. You can do this by following the below code:

-bash-3.2$ export _JAVA_OPTIONS="-Xmx256M"
-bash-3.2$ javac HelloWorldApp.java 
Picked up _JAVA_OPTIONS: -Xmx256M

answered May 31, 2018 by geek.erkami
• 2,320 points

Related Questions In Java

0 votes
3 answers

Convert date object to a String

We parse the full date to time ...READ MORE

answered Jul 30, 2018 in Java by samarth295
• 2,190 points
46 views
0 votes
3 answers

How to check whether a string is empty or not? Is there a function for this?

str != null && str.length() != 0 alternatively str ...READ MORE

answered Sep 11, 2018 in Java by Sushmita
• 6,840 points
77 views
0 votes
1 answer

How to convert a JSON String into Object in Java?

We can easily convert a JSON String ...READ MORE

answered Jun 8, 2018 in Java by parth295
• 4,600 points
208 views
0 votes
1 answer

Working of Progress Bar for a File Download

Once of the ways to achieve is ...READ MORE

answered Jun 26, 2018 in Java by Rishabh
• 3,520 points
639 views
0 votes
1 answer

how to increase heap size in java?

You can refer the below command: java -Xmx6g ...READ MORE

answered May 29, 2018 in Java by Akrati
• 3,150 points
24 views
0 votes
1 answer

Setting Proxy for JVM usage

To set an HTTP/HTTPS and/or SOCKS proxy ...READ MORE

answered Jun 26, 2018 in Java by Rishabh
• 3,520 points
168 views
0 votes
1 answer

What is the maximum Java heap size of a 32-bit JVM on a 64-bit OS?

32-bit JVMs which expect to have a ...READ MORE

answered Nov 15, 2018 in Java by Frankie
• 9,810 points
386 views
+1 vote
1 answer

What are the types of memory in JVM?

The different types of Memory in JVM ...READ MORE

answered Mar 7 in Java by Priyaj
• 56,160 points
115 views
0 votes
1 answer

Replacing a String with a character

Yes, you are missing out on a ...READ MORE

answered May 16, 2018 in Java by geek.erkami
• 2,320 points
19 views
0 votes
1 answer

Retrieving the path of a running jar file

Its quite simple. Try using the below ...READ MORE

answered May 25, 2018 in Java by geek.erkami
• 2,320 points
726 views