What are -XX:NewSize and -XX:MaxNewSize JVM parameters in java


In this core java tutorial we will learn What are -XX:NewSize and -XX:MaxNewSize JVM parameters in java, And differences between -XX:NewSize and -XX:MaxNewSize JVM parameters in java.

Contents of page >
  • What is -XX:NewSize JVM parameter in java?
    • Examples of using -XX:NewSize VM (JVM) option in java >
  • What is -XX:MaxNewSize JVM parameter in java?
    • Examples of using -XX:MaxNewSize VM option in java >
  • What are differences between -XX:NewSize and -XX:MaxNewSize JVM parameters in java?



Before learning about -XX:NewSize and -XX:MaxNewSize 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>
  1. Young Generation
    • 1a) Eden,
    • 1b) S0 (Survivor space 0)
    • 1c) S1 (Survivor space 1)
  2. Old Generation (Tenured)
  3. Permanent Generation.


What is -XX:NewSize JVM parameter in java?
-XX:NewSize - NewSize is minimum size of young generation which is allocated at initialization of JVM.

Note : If you have specified -XX:NewRatio than minimum size of the young generation is allocated automatically at initialization of JVM.

Default value of -XX:NewSize is -Xmx/5


Examples of using -XX:NewSize  VM (JVM) option in java >
Example1 of using -XX:NewSize  VM (JVM) option in java >
java -XX:NewSize =512 MyJavaProgram
It will set initial value of Permanent Space as 512 bytes to JVM.

Example2 of using -XX:NewSize  VM (JVM) option in java >
java -XX:NewSize =512k MyJavaProgram
It will set initial value of Permanent Space as 512 kilobytes to JVM

Example3 of using -XX:NewSize  VM (JVM) option in java >
java -XX:NewSize =512m MyJavaProgram
It will set initial value of Permanent Space as 512 megabytes to JVM

Example4 of using -XX:NewSize  VM (JVM) option in java >
java -XX:NewSize =1g MyJavaProgram
It will set initial value of Permanent Space as 512 gigabyte to JVM





What is -XX:MaxNewSize JVM parameter in java?
-XX:MaxNewSize - MaxNewSize is the maximum size of young generation that JVM can use.

Default value of -XX:MaxNewSize is -Xmx/5


Examples of using -XX:MaxNewSize  VM (JVM) option in java >
Example1 of using -XX:MaxNewSize  VM (JVM) option in java >
java -XX:MaxNewSize =512 MyJavaProgram
It will set initial value of Permanent Space as 512 bytes to JVM.

Example2 of using -XX:MaxNewSize  VM (JVM) option in java >
java -XX:MaxNewSize =512k MyJavaProgram
It will set initial value of Permanent Space as 512 kilobytes to JVM

Example3 of using -XX:MaxNewSize  VM (JVM) option in java >
java -XX:MaxNewSize =512m MyJavaProgram
It will set initial value of Permanent Space as 512 megabytes to JVM

Example4 of using -XX:MaxNewSize  VM (JVM) option in java >
java -XX:MaxNewSize =1g MyJavaProgram
It will set initial value of Permanent Space as 512 gigabyte to JVM


What are differences between -XX:NewSize and -XX:MaxNewSize JVM parameters in java?

-XX:NewSize JVM parameter
-XX:MaxNewSize JVM parameter
NewSize is minimum size of young generation which is allocated at initialization of JVM.
MaxNewSize is the maximum size of young generation that JVM can use.
Default value of -XX:NewSize is -Xmx/5
Default value of -XX:MaxNewSize is -Xmx/5
Example1 of using -XX:NewSize  VM (JVM) option in java >
java -XX:NewSize =512m MyJavaProgram
It will set initial value of Permanent Space as 512 megabytes to JVM

Example2 of using -XX:NewSize  VM (JVM) option in java >
java -XX:NewSize =1g MyJavaProgram
It will set initial value of Permanent Space as 512 gigabyte to JVM

Example1 of using -XX:MaxNewSize  VM (JVM) option in java >
java -XX:MaxNewSize =512m MyJavaProgram
It will set initial value of Permanent Space as 512 megabytes to JVM

Example2 of using -XX:MaxNewSize  VM (JVM) option in java >
java -XX:MaxNewSize =1g MyJavaProgram
It will set initial value of Permanent Space as 512 gigabyte to JVM






Summary -


So in this core java tutorial we learned what are -XX:NewSize and -XX:MaxNewSize JVM parameters in java, And differences between -XX:NewSize and -XX:MaxNewSize 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>


No comments:

Post a Comment