Reputation: 175
I am trying to run a certain java program with more than 1024M heap space. Even though I have 4GB of RAM and a 32bit OS, its saying that the max is 1024M. Below is the batch code I am trying to use to start the program:
@echo off
java -Xmx2048M -Xms2048M -jar program.jar
Could someone explain why I am getting a JVM "could not reserve enough space" error?
Upvotes: 0
Views: 851
Reputation: 881
You are getting the "could not reserve enough space" error because there must be no contiguous block of memory available in your RAM of size 2048M. I would suggest that you either reduce the -Xms to 512M since I don't think initially you will require 2048M heap space. If this doesnt work, then you will need to reduce the -Xmx value.
Upvotes: 0
Reputation: 229342
You're on Windows, and the max address space a single 32 bit program can have is 2GB. Now since the process and system needs some of that for housekeeping stuff (e.g. .dlls) , you can't use all those 2GB for the java heap. So try with less, e.g. 1.5 GB.
You can make 32 bit programs get 3GB of address space through a boot switch, see here , which can be an alternative to switching to a 64 bit OS if you really need more heap space.
Upvotes: 1