0

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?

trincot
  • 317,000
  • 35
  • 244
  • 286
bigbass1997
  • 175
  • 1
  • 2
  • 10
  • 1
    Not sure what OS you're running, but on Windows XP I was only able to allocate 1200-1400 MB. See http://stackoverflow.com/questions/171205 – Steve Kuo Jul 15 '12 at 04:04
  • On a 64-bit JVM you can make the heap size anything, but a practical limit is usually of the order of 100 GB (as the length of the full GC is proportional heap sixe) – Peter Lawrey Jul 15 '12 at 07:02
  • I am using a Windows 7 32bit OS with a total of 4GB of DDR3 RAM. – bigbass1997 Jul 16 '12 at 00:29

2 Answers2

1

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.

nos
  • 223,662
  • 58
  • 417
  • 506
0

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.

pyrometer
  • 890
  • 1
  • 8
  • 17