Sun HotSpot JVM Version: 1.3.1 version has been optimized, but also overcome the limitations of 2G memory on the 32-bit operating system. When setting the JVM parameter, we need to trade two important considerations for THROUGHPUT and Footprint.
The JVM memory model is divided into two blocks, one is new generation, and the other is Old Generation. In New Generation, there is a space called Eden, mainly used to store new live objects, there are two Survivor Spaces, they use To store objects that survive after each garbage collection. In the Old Generation, the memory objects for the life cycle in the application are mainly stored, and there is a Permanent Generation, mainly used to put JVM's own reflection objects, such as class objects and method objects.
In the New Generation block, garbage recycling is generally used for Copying algorithms, fast. Every time GC, the survived object is first copied by Eden to a Survivor Space. When the Survivor Space is full, the remaining Live object is copied directly to the Old Generation. Therefore, each GC will be emptied. In the Old Generation block, garbage collection generally uses Mark-Compact algorithm, slower speed, but reduces memory requirements.
There are many JVM parameters, but the most common is the following, and you can refer to the JVM white paper. Newsize, MaxNewsize, NewRatio, and Survivorratio are used to adjust the New Generation. Permsize and maxpermsize are used to adjust Permanent Generation. There is also a more familiar XMX and XMS, which are used to control the entire JVM's Heap size. Generally, we set XMX and XMS to the same value, let JVM can use AGGRESSIVE Allocated to its memory. So, we can have the following equation:
XMX = XMS = Eden 2 x Survivor Space Old Generation
TotalHeapsize = XMX setting permsize
About JVM optimization, THROUGHPUT and FOOTPRINT should be considered according to specific applications. It is not HEAP Size, because Heap size is large, and the number of GC will decrease, but the overhead of each run will increase. We can refer to the article on http://java.sun.com and http://www.javaperformanceetuning.com.