Question

Is there any drawback setting the -Xms and -Xmx to the same value? And also -XX:MaxPermSize and -XX:PermSize to same value.

It is recommended here.

If there enough physical memory available in server, is it recommended to set bit higher values to both options?

UPDATE:

Environment Java 1.6.0_45 in Solaris 10

java version "1.6.0_45"

Java(TM) SE Runtime Environment (build 1.6.0_45-b06)

Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)

Was it helpful?

Solution

Setting -xms and -xmx was a good practice in older versions of Java, when adaptive sizing wasn't working good enough. In Java >= 7 it works really nice, so it's no longer needed. If you need more details you have to read about -XX:+UseAdaptiveSizePolicy flag or refer HotSpot documentation

Another thing you have to remember about is that you have 8GB RAM on your server doesn't mean that you can use it wholly for Java. You have to left some for system buffers

In Java <= 1.6 setting XMS=XMS and same in case of PermGen is reasonable, but you have to remember about correct tuning of the XMX value, because too much memory will cause cobra effect

OTHER TIPS

  • Imagine the case when the two values are not same. In that case, JVM has the additional tasks of managing the heap size. Increasing memory whenever needed, garbage collection (not true for PermGen resulting into shrinking the size of the heap.

  • Having said that, there are lot of other factor also play very important role. For example, the way your application uses memory also determines the effect of heap size setting. Tor example, a calculation intensive standalone application will have a completely different memory requirement that a typical client-server e-commerce application which does a lot of I/O.

  • Another point to keep in mind is the underlying OS. The memory is finally allocated by OS to JVM on request and the way this happens differs from OS to OS. The only way to address is to go through the documentation of the particular JVM implementation.

So the answer to your question may not be hard and fast YES/NO . Its subjective.

In case of server application, it is recommended use to ms and mx size as a same value. The reason is when it tried to grow the memory, it will have a burden to JVM. and if heap size is same, it is easy to estimate full gc time.

In case of perm memory, after server has been warmed up. It means most of class has been loaded so perm size is not changed usally. So after u can measure the perm size by using gc log option, It is better to set fixed size of Perm.

It will be more stable in server configuration.

In addition, if u bring more bigger size of Heap (by using -mx option). It will takes more full gc time. At the full gc time, JVM is freezing. So u need to take care of max size.

In my opinion, if u have enough memory. It is better to run additional JVM instance (with clustering etc)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top