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
149 views

2 answers 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,640 points
0 votes

Run the JVM with -XX:MaxHeapSize=512m (or any big number as you need) (or -Xmx512m for short)

This should resolve it!

answered Aug 26 by Sirajul
• 36,220 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
62 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,880 points
116 views
0 votes
2 answers

How to convert a JSON String into Object in Java?

You could probably check out Google's Gson: ...READ MORE

answered Aug 21 in Java by Sirajul
• 36,220 points
391 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,540 points
1,079 views
0 votes
2 answers

how to increase heap size in java?

Here is how you can increase the ...READ MORE

answered Aug 23 in Java by Sirajul
• 36,220 points
43 views
0 votes
2 answers

Setting Proxy for JVM usage

JVM uses the proxy to make HTTP ...READ MORE

answered Aug 26 in Java by Sirajul
• 36,220 points
274 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
605 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,900 points
438 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,640 points
27 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,640 points
1,381 views