Setting Java Heap size does not work with a 64-bit 256 GB machine

I tried to find the answer to this question, but I still could not.

I have a 64-bit machine with 256 GB of RAM.

I am trying to execute a Java program that references MySQL. And he needs a quiet large heap size, because when I used the VM argument -Xmx1024m after a few minutes, this pops up:

 Exception in thread "main" java.lang.OutOfMemoryError: Java heap space 

But when I tried to set the program's VM argument to -Xmx2048m or more, it did not work and said:

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

I read that setting -Xmx2048 not a problem for a 64-bit machine, but I really don't know why it does not work on my machine.

java -version output: enter image description here

wmic OS gets FreePhysicalMemory / Value output :

 FreePhysicalMemory=251663664 

wmic computersystem gets TotalPhysicalMemory output:

 TotalPhysicalMemory 274811621376 

wmic os get osarchitecture output

 OSArchitecture 64-bit 

I could not execute systeminfo|find "Memory" because it is talking about the wrong syntax. I'm also not sure why.

+8
java memory heap-memory
source share
2 answers
 Exception in thread "main" java.lang.OutOfMemoryError: Java heap space 

This post implies that the java heap does not have enough space for further distribution. It seems you have installed 1G Xmx, which is not enough for your application, otherwise the application may miss memory that takes up space in the java heap.

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

During VM initialization. The JVM performs various initializations directly from the heap to the JIT modules. The Java heap is the continuum space during initialization if the JVM cannot find the adjacent memory space for the requested Xmx, after which an error message will be displayed.

This is a virtual memory allocation, so please do not confuse the values โ€‹โ€‹of physical memory

Run the java -verbose command: init -Xmx2048 -version

this command will report the steps that the JVM takes during initialization, and at which step it failed.

+1
source share

Consider starting the application as an administrator - just start the PowerShell console by right-clicking โ†’ Run as administrator.

Windows may prohibit the provision of large amounts of memory to a single process that runs without promotion.

Also - are you using Windows Server or a version of Windows for workstations? It is generally recommended that you use Windows Server for these "large" services.

0
source share

All Articles