I am running java process through main class on java 8. I have not specified anywhere min(Xms) and max(Xmx) heap size. But when i check through visualVM it's
4267704320(i.e. 4.26 GB) which is the default max heap size for a given process(confirmed through windows command also which is
-XX:+PrintFlagsFinal -version 2>&1 | findstr MaxHeapSize
. similarly on linux box too).
My question is if my process(on linux machine) requires more 5 GB(i have 30 GB RAM), will my process be allocated 5 GB memory when i have not specified any explicit heap size(Xms and Xmx) parameters.
Given your the available RAM on your machine, if you are running a 64-bit JVM in server mode, then yes, the heap size will be able to go up to approximately 7.5 GB.
Documentation (I highlighted the relevant parts):
Client JVM Default Initial and Maximum Heap Sizes
The default maximum heap size is half of the physical memory up to a physical memory size of 192 megabytes (MB) and otherwise one fourth of the physical memory up to a physical memory size of 1 gigabyte (GB).
Server JVM Default Initial and Maximum Heap Sizes
The default initial and maximum heap sizes work similarly on the server JVM as it does on the client JVM, except that the default values can go higher. On 32-bit JVMs, the default maximum heap size can be up to 1 GB if there is 4 GB or more of physical memory. On 64-bit JVMs, the default maximum heap size can be up to 32 GB if there is 128 GB or more of physical memory. You can always set a higher or lower initial and maximum heap by specifying those values directly; see the next section.
Again, assuming a 64-bit JVM running in server mode, the default max heap size according to the documentation will be one fourth of your total RAM. So approximately 7.5 GB in your case (1/4 of 30 GB).
If running a 32-bit JVM in server mode, you'll be capped at 1 GB. And in client mode, your max will be 256 MB.
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