There are many posts and sites about heap size, but none of them mention how to find out the maximum heap size that I can reserve when calling jvm.
The task is to start my jvm dynamically with the maximum heap size xmx = max (there is no need to discuss the object of this task here!).
You might consider reading the current available or free memory and using this size for xms and xmx. but it does not work.
for example, on a 64-bit machine and Windows os, with 24 GB of RAM, about 1.8 GB of available virtual memory: (those that were identified by C # that executes the Java command in the process)
jvm starts with 32 bit! And according to other sites and posts, like: The maximum Java heap size of a 32-bit JVM on a 64-bit OS , it should be above 1.4 GB.
[09.07.2015 08:39:39] Total physical memory MB: 24002 [09.07.2015 08:39:39] Available physical memory MB: 16115 [09.07.2015 08:39:39] Total virtual memory MB: 2047 [09.07.2015 08:39:39] Available virtual memory MB: 1810
calling a Java program with:
java -Xms1536m -Xmx1536m myApp
lead to:
Failed to reserve enough space for the heap of objects 1572864KB
the same thing happens up to 1136 m, which is the maximum possible!
So my question is: how to check the heap size possible for jvm call without trial error?
UDPATE: Based on these comments, I raise one more question for all who are there: How do you guys launch a Java application?
- Select the heap you checked. It takes approx. and let the user die in error if this heap is not possible.
- Trial error: lower the heap and try again until a valid maximum heap is found
- Use this secret way to determine the guaranteed maximum heap size and smoothly execute it (if so, put your circle of trust :))
I am absolutely curious about your answers!
source share