Some parameters to make up for the disadvantages of the CMS (Concurrent mark-sweep) collector

Source: Internet
Author: User
Tags garbage collection memory usage
1. On the question of fragmentation:CMS using the Mark-sweep algorithm for garbage will not be organized and compressed heap space, after each recovery will inevitably have some debris.
-xx:+usecmscompactatfullcollectionDefault true compresses older years and may affect performance, but can eliminate fragmentation.
-xx:cmsfullgcsbeforecompaction=n CMS to perform a compression after N-time full GC. If n=0, fragmentation is compressed after each full GC.
2. About CPU IssuesCMS requires more "nuclear" CPU, in the CMS activities, will occupy more "nuclear".
–xx:+cmsincrementalmodeDefault false concurrent collection increment, periodically to the CPU resources to the running application.
–xx:+cmsincrementalpacingDefault false automatically adjusts the number of garbage collection tasks performed per execution based on the behavior of the application
–xx:parallelgcthreads=n(Ncpus <= 8)? Ncpus:3 + ((Ncpus * 5)/8) concurrent garbage collection thread count
-xx:cmsincrementaldutycyclemin=nDefault 0 Minimum percentage of total garbage collection tasks per incremental garbage collection
-xx:cmsincrementaldutycycle=nDefault 10 Percentage of total garbage collection tasks per incremental garbage collection
3. With regard to space issuesCMS requires more memory, on the one hand, fragmentation problem, on the other hand, is not in the old age of the full time, but when the old era of memory to achieve a certain proportion.
-xx:cmsintiatingoccupancyfractio=nWhen old age memory usage reaches n%, jdk5 default is 68% jdk6 default 92%cmsinitiatingoccupancyfraction = (100-minheapfreeratio) + (Cmstriggerratio * Min HEAPFREERATIO/100)

A few experiences:
1. Java-server
2. Set XMS=XMX=3/4 physical memory
3. If it is CPU intensive server, use –XX:+USEPARALLELOLDGC, otherwise –XX:+USECONCMARKSWEEPGC
4. Cenozoic, Parallel/parallelold can be set larger than xmx1/4,cms can be set small, less than XMX1/4
5. Optimization procedures, especially for each user in the session of the collection class. One of our modules in the session has been used for each user a concurrenthashmap, there are usually only a few records, and then after the group, each machine probably saved 1~2g memory.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.