For the majority of applications, the default settings work well. The heap expands until it reaches a steady state, then remains in that state, which should give a heap occupancy (the amount of live data on the heap at any given time) of 70%. At this level, the frequency and pause time of garbage collection should be acceptable.
For some applications, the default settings might not give the best results. Listed here, are some problems that might occur, and some suggested actions that you can take. Use verbosegc to help you monitor the heap.The frequency of garbage collections is too high until the heap reaches a steady state. Use verbosegc to determine the size of the heap at a steady state and set -Xms to this value. The heap is fully expanded and the occupancy level is greater than 70%. Increase the -Xmx value so that the heap is not more than 70% occupied, but for best performance try to ensure that the heap never pages. The maximum heap size should, if possible, be able to be contained in physical memory. At 70% occupancy the frequency of garbage collections is too great. Change the setting of -Xminf. The default is 0.3, which tries to maintain 30% free space by expanding the heap. A setting of 0.4, for example, increases this free space target to 40%, and reduces the frequency of garbage collections. Pause times are too long. Try using -Xgcpolicy:optavgpause. This reduces the pause times and makes them more consistent when the heap occupancy rises. It does, however, reduce throughput by approximately 5%, although this value varies with different applications.
Here are some useful tips:
来自 “ ITPUB博客 ” ，链接：http://blog.itpub.net/27378/viewspace-582495/，如需转载，请注明出处，否则将追究法律责任。