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
977 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,680 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, 2019 by Sirajul
• 59,230 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 31, 2018 in Java by samarth295
• 2,220 points
1,220 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,910 points
988 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, 2019 in Java by Sirajul
• 59,230 points
3,034 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,620 points
5,959 views
0 votes
2 answers

how to increase heap size in java?

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

answered Aug 23, 2019 in Java by Sirajul
• 59,230 points
1,534 views
0 votes
2 answers

Setting Proxy for JVM usage

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

answered Aug 26, 2019 in Java by Sirajul
• 59,230 points
2,272 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,830 points
2,660 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, 2019 in Java by Priyaj
• 58,090 points
2,635 views
0 votes
1 answer

Replacing a String with a character

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

answered May 17, 2018 in Java by geek.erkami
• 2,680 points
425 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,680 points
10,320 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP