I have two Linux machines (both are virtual machines), one of which has 12 GB of memory, and the other is 8 GB.
I tried to run the same java program on both machines with the maximum maximum heap size (using the -Xmx flag). Below are the results that I got.
- 12GB machine: 9460MB
- 8GB machine: 4790MB
If I specify the maximum heap size beyond the above limits, I get below error.
Error occurred during initialization of VM
Could not allocate metaspace: 1073741824 bytes
I checked the free memory on two systems (using the command free) and I got the following.
- 12GB machine: approximately 3GB free.
- 8GB machine: approximately 4GB free.
, , java-, ? ( 1073741824 , )