I have been trying to find the answer to this but I still could not.
I have a 64-bit machine with 256 GB RAM.
I am trying to execute a Java program which links to MySQL. And it needs a quiet big heap size because when I used VM argument -Xmx1024m
after few minutes this pops up:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
But, when I tried to set the program VM argument by -Xmx2048m
or bigger, it does not work and said:
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap
I read that setting -Xmx2048
is not a problem for 64-bit machine but I really do not know why it's not working on my machine.
java -version
output:
wmic OS get FreePhysicalMemory /Value output:
FreePhysicalMemory=251663664
wmic computersystem get TotalPhysicalMemory output:
TotalPhysicalMemory
274811621376
wmic os get osarchitecture output
OSArchitecture
64-bit
I could not execute systeminfo|find "Memory"
as it says wrong syntax. Im not sure why either.
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
This message implies the java heap does not have enough space to do further allocation. It seems you have set to 1G of Xmx which is insufficient for your application else the application might leak memory which occupies space in java heap.
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap
During VM initialization. JVM does various init right from Heap to JIT modules. Java heap are continiuos space while doing doing initialization if JVM could not find the contigous memory space for the requested Xmx then above error message will be thrown.
These are virtual memory allocation so please do not confuse with physical memory values
Please run the command java -verbose:init -Xmx2048 -version
this command will tell the steps undergoes by JVM while doing initialization and during what step it got failed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With