Specified VM Args like Xmx in the java command multiple times
One day during the discussion with our colleagues received the following query:
Q:
If we specify -Xms and -Xmx values twice/more in the java command, which one will reflect?
We thought for some time and come out with different answers for the same. Hence, decided to test in detailed for the proper answer. Hence, started the testing as follows:
1. java -Xms256m -Xmx256m -XX:PermSize=128m -XX:MaxPermSize=256m -Xms256m -Xmx256m Test
Fortunatly, we are using JDK 1.6 which contains jconsole utility to identify the memory utilization details. We see the following:
Maximum heap size: 253,440 kbytes
2. java -Xms256m -Xmx256m -XX:PermSize=128m -XX:MaxPermSize=256m -Xms256m -Xmx512m Test
Maximum heap size: 506,816 kbytes
3. java -Xms256m -Xmx256m -XX:PermSize=128m -XX:MaxPermSize=256m -Xms256m -Xmx1024m Test
Maximum heap size: 1,013,632 kbytes
4. java -Xms256m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=256m -Xms256m -Xmx256m Test
Maximum heap size: 253,440 kbytes
5. java -Xms256m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=256m -Xms256m -Xmx256m Test
Maximum heap size: 253,440 kbytes
6. java -Xms256m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=256m -Xms512m -Xmx512m -Xms256m -Xmx256m Test
Maximum heap size: 253,440 kbytes
From the above experiment, it confirms that the Xms and Xmx values are reflected which comes in the last position of command. From this, it appears that the values are pushed in to the stack and pop the values using LIFO method.

If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Comments
No comments yet.
Leave a comment