Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

Default parameters of XMS and XMX in JVM

Can someone explain the purpose of xms and xmx parameters? Also, what are the default values these parameters during JVM startup?
by

3 Answers

espadacoder11
The flag Xmx specifies the maximum memory allocation pool for a Java virtual machine (JVM), while Xms specifies the initial memory allocation pool.

The Xms flag has no default value, and Xmx typically has a default value of 256 MB. A common use for these flags is when you encounter a java.lang.OutOfMemoryError.
sandhya6gczb
The flag Xmx specifies the maximum memory allocation pool for a Java Virtual Machine (JVM), while Xms specifies the initial memory allocation pool.

This means that your JVM will be started with Xms amount of memory and will be able to use a maximum of Xmx amount of memory. For example, starting a JVM like below will start it 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 also be specified in different sizes, such as kilobytes, megabytes, and so on.

-Xmx1024k
-Xmx512m
-Xmx8g

The Xms flag has no default value, and Xmx typically has a default value of 256 MB. A common use for these flags is when you encounter a java.lang.OutOfMemoryError.

When using these settings, keep in mind that these settings are for the JVM's heap, and that the JVM can and will use more memory than just the size allocated to the heap.
pankajshivnani123
You use these Java command-line parameters to help control the RAM use of application:

-Xmx to specify the maximum heap size
-Xms to specify the initial Java heap size

Login / Signup to Answer the Question.