Cannot start 64-bit JVM on 64-bit Windows 7 with large heap size

This is 64-bit Windows 7 Enterprise and 64-bit Java 7:

 java version "1.7.0_04" Java(TM) SE Runtime Environment (build 1.7.0_04-b20) Java HotSpot(TM) 64-Bit Server VM (build 23.0-b21, mixed mode) 

This happens using a shell like C:\Windows\SystemWOW64\cmd.exe (which I incorrectly thought was the 64-bit version) and with C:\Windows\System32\cmd.exe (which I just found out, kindly provided by Pulsar, 64 bit application, despite the path name).

The program itself is trivial:

 public class Trivial { public static void main(String[] args) { System.out.println("total = " + toMB(Runtime.getRuntime().totalMemory())); System.out.println("max = " + toMB(Runtime.getRuntime().maxMemory())); } private static long toMB(long bytes) { return bytes / (1024L * 1024L); } } 

I simply cheated on the different arguments -Xmx and -Xms to see what happens. I would like, although with 64-bit Java on 64-bit Windows, I could use almost any max size and the initial heap I wanted, but that is not what happens.

java -Xmx16G -Xms2G Trivial (for example) is working fine. However, java -Xmx16G -Xms4G Trivial gives me:

 Error occurred during initialization of VM Could not reserve enough space for object heap 

Weirder (for me), java -Xmx16G -Xms3G Trivial gives another error:

 Error occurred during initialization of VM Unable to allocate tables for parallel garbage collection for the requested heap size. Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. 

Trying to split the difference between 2G and 3G to see if the specific size was where it happened, I tried java -Xmx16G -Xms2900M Trivial and it worked. Then I tried -Xms2960M and it worked. With -Xms2970m JVM crashed:

 # # There is insufficient memory for the Java Runtime Environment to continue. # Native memory allocation (malloc) failed to allocate 1048576 bytes for E in C:\jdk7u2_64p\jdk7u4\hotspot\src\share\vm\utilities/taskqueue.hpp # An error report file with more information is saved as: # C:\Users\QuantumMechanic\Temp\hs_err_pid10780.log 

This continued until -Xms2995M , when he again switched to the message "tables could not be allocated for parallel garbage collection" and stuck with it as -Xms .

What could be? Does anything from cmd.exe (even 64-bit) run any process size limits? Does Windows (or JVM) require one huge block of memory? (But then why different messages)? Something else?

+8
java memory-management windows 64bit
source share
2 answers

On a 64-bit system, you have 2 ^ 63Bytes of user address space , but you can only display the amount of actual memory (file + + file + associated files).

When the JVM creates a heap, it uses C malloc() to request the initial piece of memory, and then it will manage the piece itself . Even if you don't have an object on the heap at all, the OS uses a chunk.

Since you specified -Xms , which is the minimum value of the memory pool, the JVM will simply try to require the amount of memory from the OS or fail because it cannot satisfy your command.

I think if you want to see the advantage of 64-bit Java. Perhaps you can try to open a file larger than 4 GB for random access and map it to MappedByteBuffer.

+3
source share

SysWoW64 refers to 32-bit Windows on Windows 64 . Simplified: 32-bit windows running on Windows 64bit).

So, you explicitly request a launch in the 32-bit CMD shell.

Please look:

http://en.wikipedia.org/wiki/WoW64

+5
source share

All Articles