You are here : Home / Core Java Tutorials / Series of JVM and Garbage Collection (GC) in java - Best explanations ever
In this core java tutorial we will learn What are -Xms and -Xmx JVM parameters in java, And differences between -Xms and -Xmx JVM parameters in java.
Contents of page >
- 1) What is -Xms JVM parameter in java?
- Examples of using -Xms VM (JVM) option in java >
- 2) What is -Xmx JVM parameter in java?
- Examples of using -Xmx VM option in java >
- 3) What are differences between -Xms and -Xmx JVM parameters in java?
Before learning about -Xms and -Xmx JVM parameters in java we must know about java heap memory structure.
Earlier we read about JVM Heap memory (Hotspot heap structure) in java consists of following elements>
- Young Generation
- 1a) Eden,
- 1b) S0 (Survivor space 0)
- 1c) S1 (Survivor space 1)
- Old Generation (Tenured)
- Permanent Generation.
1) What is -Xms JVM parameter in java?
-Xms : Xms is minimum heap size which is allocated at initialization of JVM in java.
Examples of using -Xms VM (JVM) option in java >
Example1 of using -Xms VM (JVM) option in java >
java -Xms512 MyJavaProgram
It will set the minimum heap size of JVM to 512 bytes.
Example2 of using -Xms VM (JVM) option in java >
java -Xms512k MyJavaProgram
It will set the minimum heap size of JVM to 512 kilobytes.
Example3 of using -Xms VM (JVM) option in java >
java -Xms512m MyJavaProgram
It will set the minimum heap size of JVM to 512 megabytes.
Example4 of using -Xms VM (JVM) option in java >
java -Xms1g MyJavaProgram
It will set the minimum heap size of JVM to 1 gigabyte.
2) What is -Xmx JVM parameter in java?
-Xmx : Xmx is the maximum heap size that JVM can use.
Examples of using -Xmx VM option in java >
Example1 of using -Xmx VM (JVM) option in java >
java -Xmx512 MyJavaProgram
It will set the maximum heap size of JVM to 512 bytes.
Example2 of using -Xmx VM (JVM) option in java >
java -Xmx512k MyJavaProgram
It will set the maximum heap size of JVM to 512 kilobytes.
Example3 of using -Xmx VM (JVM) option in java >
java -Xmx512m MyJavaProgram
It will set the maximum heap size of JVM to 512 megabytes.
Example4 of using -Xmx VM (JVM) option in java >
java -Xmx1g MyJavaProgram
It will set the maximum heap size of JVM to 1 gigabyte.
Read in detail about : OutOfMemoryError in java
3) What are differences between -Xms and -Xmx JVM parameters in java?
-Xms JVM parameter
|
-Xmx JVM parameter
|
Xms is minimum heap size which is allocated at initialization of JVM in java.
|
Xmx is the maximum heap size that JVM can use.
|
Examples of using -Xms VM (JVM) option in java >
Example1 of using -Xms VM (JVM) option in java >
java -Xms512m MyJavaProgram
It will set the minimum heap size of JVM to 512 megabytes.
Example2 of using -Xms VM (JVM) option in java >
java -Xms1g MyJavaProgram
It will set the minimum heap size of JVM to 1 gigabyte.
|
Examples of using -Xmx VM option in java >
Example1 of using -Xmx VM (JVM) option in java >
java -Xmx512m MyJavaProgram
It will set the maximum heap size of JVM to 512 megabytes.
Example2 of using -Xmx VM (JVM) option in java >
java -Xmx1g MyJavaProgram
It will set the maximum heap size of JVM to 1 gigabyte.
|
Summary -
So in this core java tutorial we learned what are -Xms and -Xmx JVM parameters in java, And differences between -Xms and -Xmx JVM parameters in java.
Having any doubt? or you liked the tutorial! Please comment in below section.
Please express your love by liking JavaMadeSoEasy.com (JMSE) on facebook, following on google+ or Twitter.
RELATED LINKS>