To find the default jav heap sizes
java -XX:+PrintFlagsFinal -version | findstr HeapSize
java -XX:+PrintFlagsFinal -version | findstr HeapSize
On a Unix/Linux,
java -XX:+PrintFlagsFinal -version | grep HeapSize
For our application, Java heap sizes can be set by (Suffixes for the memory size are G for gigabytes, M for megabytes, or K for kilobytes.)
Max heap size: Java -Xmx512m <classname>
Min heap size: Java -Xms64m <classname>
It is important to note that the JVM will not allocate this memory in its entirety on startup; it will grow to a maximum of that size only if needed. Before the JVM expands its memory allocation, it will try to perform as much garbage collection as possible.
Xms This argument is advisable if you know you are going to need a certain amount of memory for your function, as it will save your application from excessive slow garbage collections before expanding to your required size.
If both arguments are set to the same value, the JVM will ask the operating system for that full memory allocation on startup, and it will not grow any larger.
Default memory:
For the initial memory allocation, the default value is 1/64 of the memory on the computer, up to 1 GB.
For the maximum default, it is the smaller of 1 GB and a quarter of the computer’s physical memory.