2

I am unable to run java if I set Xmx to 967 or a higher value.

C:\Documents and Settings\salesforce>java -Xmx967m -version 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.

If I run the same command, but setting Xmx to 966, it runs correctly:

C:\Documents and Settings\salesforce>java -Xmx966m -version java version "1.7.0_25" Java(TM) SE Runtime Environment (build 1.7.0_25-b17) Java HotSpot(TM) Client VM (build 23.25-b01, mixed mode)

Before executing the command 3GB of ram are available (task manager).

Environment:

  • Java 1.7.0_25 32bits
  • Windows server 2003 SP2, 4GB RAM
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Fran Montero
  • 1,679
  • 12
  • 24

1 Answers1

0

The JVM uses a bit more than just the heap size for internals. That may easily account for a few hundred MB depending on how you configured things (perm space, thread stack size, number of threads, etc.). You are using the 32 bit jvm so the max process size would be 2GB on windows 32 bit, I believe. I believe there are ways to expand that to 3GB (e.g. http://dwf.blogs.com/beyond_the_paper/2009/04/enabling-3gb-switch-on-windows-vista.html has some explanation on this) ; but it's been a while since I was in that kind of environment. So you are probably running close to the limit.

Jilles van Gurp
  • 7,927
  • 4
  • 38
  • 46
  • Thanks for your answer, but i believe that there must be something else. Setting max heap to 967 is not reaching 2GB process limit for sure. – Fran Montero Jul 21 '15 at 09:10
  • If it is telling you it is out of memory, typically it is not lying. Your assumption that you have enough memory is probably wrong for some reason. You seem to have narrowed it down to the exact amount you can still create a heap with. heap != allocated memory. Heap is the bit available to your program but the jvm also allocates memory outside of this area. Also if you are loading any native stuff from java that might allocate off heap memory. So, clearly something doesn't fit. Impossible to tell what without more info. – Jilles van Gurp Jul 21 '15 at 13:24
  • What info do you need ?? – Fran Montero Jul 22 '15 at 06:24