The XMX parameter helps in signifying and mentioning the maximum space allocation for a Java Virtual Machine (JVM), while the XMS parameter mentions the initial storage allocation pool, respectively. This further states that the JVM will be started with XMS amount of storage and will be able to use a maximum of XMX amount of storage. Suppose for starting a JVM like displayed below, it will start with 256 MB of memory and will allow the process to use up to 2048 MB of memory:
java -Xms256m -Xmx2048m
The memory flag can and will also be differentiated in different sizes, such as kilobytes, megabytes, and so on.
-Xmx1024k -Xmx512m -Xmx8g
The XMX usually has a given default value of 256 MB but however, there is no default value for the XMS flag. At a time when one encounters the following code, a mutual benefit for both the flags is denoted.
java.lang.OutOfMemoryError
These settings shown are used for JVM’s heap and the given JVM has the ability and often does use more memory than just the allocated size to the heap. For instance, in the Java methods, the many ranging thread stacks and native handles are allotted in memory spaces which are not stored in the same place as the heap, as well as the JVM internal data structures.