my dog learned polymorphism*
The moose likes Ant, Maven and Other Build Tools and the fly likes error occurred during intialization of VM could not reserve enough space for object heap & ant Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "error occurred during intialization of VM could not reserve enough space for object heap & ant" Watch "error occurred during intialization of VM could not reserve enough space for object heap & ant" New topic
Author

error occurred during intialization of VM could not reserve enough space for object heap & ant

Michele Smith
Ranch Hand

Joined: Oct 27, 2010
Posts: 412
Hello when I run this:

ant -version


I get the above referenced error, reprinted here for ease or convenience:

error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the JAva VM


I should mention that I did follow the installation instructions on the link here:

http://ntiertraining.com/tutorials/apache/ant/tutorial_install_ant/index.htm

of ant.

I also changed my environment variable ANT_OPTs like this:

-Xmx1500m -XX:MaxPermSize=2000m -Dcom.sun.aas.instanceName=server

Any Help would be appreciated.

I am running Windows 32 Windows Server 2008 SP2 with 2 Gigabytes of RAM.
Joe carco
Ranch Hand

Joined: Apr 14, 2009
Posts: 82
-Xmx1500m -XX:MaxPermSize=2000m -Dcom.sun.aas.instanceName=server


1. What exactly do you need 1,5 gig of RAM for when using ANT? What exactly are you launching with ant that requires so much space?
If you just plan on doing a normal ant build, even with very large scripts an huge plugins, I'm sure that 512 MB will suffice.

2. I've never come across, not even the largest JEE Application Server deployments that require 2 GB of PermGen Space. I not even sure if that amount is allowed at all on a JVM, 32 or 64 bit versions.

I am running Windows 32 Windows Server 2008 SP2 with 2 Megabytes of RAM.


That explains it! your running WIndows Server with only 2 Megs of RAM
No seriously, I'll assume you meant 2 GB - if so you can never allocate more Heap + PermGen than you physically have on your system. I believe a 32 Bit JVM won't even let you set 1500 MB of Heap space. I've observed that on 32 Bit windows, the JVM won't let you set Heap sizes larger than 1200 - 1300 MB. Only 64 Bit JVMs let you set sizes beyond that.

A reasonable setting could be -Xmx256m (if you run out you can alway increase Heap)
Try not to change the PermSize defaults (i.e dont specify a MaxPermSize) if Ant crashes reporting a PermGen problem you can alway set a higher value like 128 MB PermGen

I'm not supposing all of my comments above are fact or true, they're all just based on experience and observations I have made with fairly large Java applications, so please correct me if I'm wrong
Michele Smith
Ranch Hand

Joined: Oct 27, 2010
Posts: 412
You are right, it is Gb, not Mb, my bad.

Okay well let me state this: I am absolutely a newbie. The specifications for the software I am building state we need 4 gb. of RAM. We only have 2 gb of RAM. I have tried to use "more reasonable" as you say, minimum and maximum heap sizes, and just got sick of it erroring out and adjusted it too much, again, my bad, maybe it is crashing at this point.

I guess what I am saying is, thanks for your help, I just need someone to help me understand my problem. Is it RAM on a 32 bit machine, is it heap size, is it specifying a max heap size? Should I just get rid of the max heap size specification in the environment variable?

What could I do to make this error in the subject line go away?

Thanks,
Michele
Joe carco
Ranch Hand

Joined: Apr 14, 2009
Posts: 82
I dont quite understand... are you saying that the specs say that the software you are building requires 4 gig? surely that doesn't apply to the software needed to build the target software?

Assuming you mean the software that is built by ant: try not to adjust any memory settings when building with ant, if you do run out of memory during the build process, increase it to, say 128 MB Heap and start again, if you still run out maybe add another 128MB.

What I'm trying to say is Ant usually works just fine without changing any settings to the memory and leaving it to its defaults
Michele Smith
Ranch Hand

Joined: Oct 27, 2010
Posts: 412
you won't believe how I got this error to go away.

I got rid of the max heap size completely and it works like a charm.

So now it only says this on my environment variable:

-Xmx512m -Dcom.sun.aas.instanceName=server

That's it!

It got rid of the error and I was able to verify that ant was installed.

Am I right that there is no max heap size specified on there now?

Okay you asked about the application, yes, the application that I am running will require 4 gig of RAM it said in the specifications. We have run server logs that also show utilization of about 1.2 gigs.

We are not just using ant, we are using a plethora of other things as well. You keep saying that you cannot believe an application would require 4 gig of RAM with ant. I am sorry this is so unbelievable believe me.

Respond when you can and have a nice thanksgiving.

Best Wishes,
Michele
Joe carco
Ranch Hand

Joined: Apr 14, 2009
Posts: 82

I'm glad I could help you - still I think youre missing something:

Michele Smith wrote:
We are not just using ant, we are using a plethora of other things as well. You keep saying that you cannot believe an application would require 4 gig of RAM with ant. I am sorry this is so unbelievable believe me.


I still wont believe it. You said you launched ant with 512MB heap therefore you will never be able to run an ant instance with more than 512MB with that configuration. Are you sure you're not just using ant to build the project? and the built result, after ant has finished, is some kind of application that requires 4 Gigs max?

In my company whe have a j2ee application that uses up to 6 GB of Heap backed by a huge 80 Gb MySQL database. This application is also just build with ant without having to adjust any memory settings to ant.

I'm just curious because I have never come across an ant build script that requires 4 GB of heap space.
Michele Smith
Ranch Hand

Joined: Oct 27, 2010
Posts: 412
Hi, Joachim, like I said I am a total newbie, and yes, ant is building the application and the application requires 4 gigabytes of RAM.

The application is called the NHIN Gateway. There is an open source community for it but they don't post regularly there anymore in the forums, so I have had to weigh heavily upon this forum for help.

Thanks Joachim for the pointers and the heads up!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: error occurred during intialization of VM could not reserve enough space for object heap & ant
 
Similar Threads
java.lang.OutOfMemory
error in initialization of VM
Could not reserve enough space for object heap
Ant : Error occurred during initialization of VM
compile error