"-xmx1024m-xms1024m-xmn512m-xss256k"--java Run parameters

Source: Internet
Author: User
Tags xms

"Java Learning" "-xmx1024m-xms1024m-xmn512m-xss256k"--java run parameters reprinted June 13, 2016 19:33:38 2792 Young generation concept of the old generation/HTTP The memory of the heap of the jefferent.iteye.com/blog/1123677 JVM is the size of the-XMS minimum heap controlled by the two parameters below, that is, when your virtual machine starts, it allocates so much heap memory to you-XMX is the largest heap size when the smallest heap fills up, Will attempt to perform GC, if the GC does not get enough memory (GC may not collect all the currently available memory), allocate new objects, then the heap will be expanded, if-XMX is set too small, the extension heap will fail, resulting in outofmemoryerror error. In fact, the details are more than this, the heap will be divided into several different areas, respectively, the use of different GC algorithm-------------------------------Google to a blog post, posted, Long look:/http UNIXBOY.JAVAEYE.COM/BLOG/174173JVM Tuning Summary-xms-xmx-xmn-xss Heap size Setting the maximum heap size in the JVM has three limitations: the data model of the associated operating system (32-BT or 64-bit) limits ; The available virtual memory limits of the system; the available physical memory limits for the system. Under the 32-bit system, the 1.5g~2g;64 is generally limited to memory unrestricted for the operating system. I test under Windows Server 2003 System, 3.5G physical memory, JDK5.0, Max can be set to 1478m. Typical setup: java-xmx3550m-xms3550m-xmn2g-xss128k-xmx3550m: Sets the JVM's maximum available memory to 3550M. -xms3550m: Set the JVM to drive memory to 3550m. This value can be set to the same as-xmx to avoid the JVM reallocating memory after each garbage collection completes. -XMN2G: Set the young generation size to 2G. The entire JVM memory size = younger generation size + old generation size + persistent generation size. The permanent average fixed size is 64m, so increasing the younger generation will reduce the size of older generations. This value has a large impact on system performance, and Sun's official recommendation is 3/8 for the entire heap. -xss128k: Sets the stack size for each thread. After JDK5.0, each thread has a stack size of 1M, before each thread has a stack size of 256K. The size of the memory required for the more applied threads to be adjusted. In the same physical memory, reducing this value can generate more threads. But the operating systemRange the number of threads is still limited, can not be generated indefinitely, the experience value of 3000~5000 around. java-xmx3550m-xms3550m-xss128k-xx:newratio=4-xx:survivorratio=4-xx:maxpermsize=16m-xx:maxtenuringthreshold=0- Xx:newratio=4: Sets the ratio of the young generation (including Eden and the two survivor zone) to the old generation (except for the persistent generation). Set to 4, the ratio of the young generation to the old generation is 1:4, and the young generation occupies the 1/5-xx:survivorratio=4 of the entire stack: set the ratio between the Eden and survivor areas of the young generation. Set to 4, the ratio of two survivor to one Eden area is 2:4, and one survivor area represents the 1/6-xx:maxpermsize=16m of the entire young generation: Set the persistent generation size to 16m. -xx:maxtenuringthreshold=0: Sets the maximum age for garbage. If set to 0, then the young generation object does not go through the survivor area, directly into the old generation. For older generations of more applications, can improve efficiency. If this value is set to a larger value, the younger generation objects are duplicated multiple times in the Survivor area, which increases the survival time of the object's younger generations, increasing the introduction of being recycled in the younger generation. The collector chooses the JVM to give three choices: the serial collector, the parallel collector, the concurrent collector, but the serial collector is only for small amounts of data, so the choice here is primarily for the parallel collector and the concurrency collector. By default, JDK5.0 used a serial collector before, and if you want to use a different collector, you need to add the appropriate parameters at startup. After JDK5.0, the JVM is judged based on the current system configuration. Throughput-first parallel collectors as described above, the parallel collector is mainly to reach a certain throughput target, applicable to science and technology and background processing. Typical configuration: java-xmx3800m-xms3800m-xmn2g-xss128k-xx:+useparallelgc-xx:parallelgcthreads=20-xx:+ USEPARALLELGC: Select the garbage collector as the parallel collector. This configuration is only valid for younger generations. In this configuration, the younger generation uses concurrent collection, while the older generation still uses serial collection. -XX:PARALLELGCTHREADS=20: Configures the number of threads for a parallel collector, that is, how many threads are garbage collected together. This value is best configured to be equal to the number of processors. Java-xmx3550m-xms3550m-xmn2g-xSS128K-XX:+USEPARALLELGC-XX:PARALLELGCTHREADS=20-XX:+USEPARALLELOLDGC-XX:+USEPARALLELOLDGC: Configure the old Generation garbage collection method for parallel collection. JDK6.0 supports parallel collection of older generations. JAVA-XMX3550M-XMS3550M-XMN2G-XSS128K-XX:+USEPARALLELGC-XX:MAXGCPAUSEMILLIS=100-XX:MAXGCPAUSEMILLIS=100: Set the maximum time for each young generation of garbage collection, and if this time is not met, the JVM will automatically adjust the younger generation size to meet this value. java-xmx3550m-xms3550m-xmn2g-xss128k-xx:+useparallelgc-xx:maxgcpausemillis=100-xx:+useadaptivesizepolicy-xx:+ Useadaptivesizepolicy: When this option is set, the parallel collector automatically selects the size of the younger generation and the corresponding Survivor area scale to achieve the minimum corresponding time specified by the target system or the collection frequency, etc., which is recommended to be turned on when using the parallel collector. Concurrency collector with response time precedence as described above, the concurrency collector is primarily a guarantee of system response times, reducing the time to pause during garbage collection. It is suitable for application server, telecom field and so on. Typical configuration: java-xmx3550m-xms3550m-xmn2g-xss128k-xx:parallelgcthreads=20-xx:+useconcmarksweepgc-xx:+useparnewgc-xx:+ USECONCMARKSWEEPGC: Set old age on behalf of concurrent collection. After configuring this in the test, the configuration of the-xx:newratio=4 is invalid for unknown reasons. Therefore, at this time the younger generation size is best set with-XMN. -XX:+USEPARNEWGC: Set Young on behalf of the parallel collection. Can be used concurrently with CMS collection. JDK5.0 above, the JVM will set itself according to the system configuration, so it is no longer necessary to set this value. java-xmx3550m-xms3550m-xmn2g-xss128k-xx:+useconcmarksweepgc-xx:cmsfullgcsbeforecompaction=5-xx:+ Usecmscompactatfullcollection-xx:cmsfullgcsbeforecomPaction: Because the concurrent collector does not compress and defragment the memory space, it can produce "fragmentation" after a period of time, which makes the operation less efficient. This value sets how many times a GC is run to compress and defragment the memory space. -xx:+usecmscompactatfullcollection: Turn on compression for older generations. May affect performance, but can eliminate fragmentation secondary information The JVM provides a number of command-line arguments that print information for debugging purposes. The main ones are:-XX:+PRINTGC output: [GC 118250k->113543k (130112K), 0.0094143 secs] [Full GC 121376k->10414k (1301 12K), 0.0650971 secs]-xx:+printgcdetails output form: [GC [defnew:8614k->781k (9088K), 0.0123035 secs] 118250k->113543k ( 130112K), 0.0124633 secs] [GC [defnew:8614k->8614k (9088K), 0.0000665 secs][tenured:112761k->10414k ( 121024K), 0.0433488 secs] 121376k->10414k (130112K), 0.0436268 secs]-xx:+printgctimestamps-xx:+ Printgc:printgctimestamps can be mixed with the above two output form: 11.851: [GC 98328k->93620k (130112K), 0.0082960 secs]-xx:+ Printgcapplicationconcurrenttime: The execution time of the program is not interrupted before each garbage collection is printed. Can be mixed with the above output form: Application time:0.5291524 Seconds-xx:+printgcapplicationstoppedtime: The time the program was paused during the printing garbage collection. Can be mixed with above output form: Total time for which application threads were stopped:0.0468229 SECONDS-XX:PRINTHEAPATGC: detailed stack information before and after printing GCOutput form: 34.702: [GC {HEAP before GC invocations=7:def new generation Total 55296K, used 52568K [0x1ebd0000, 0x227d0000, 0x 227d0000) Eden Space 49152K, 99% used [0x1ebd0000, 0x21bce430, 0x21bd0000) from space 6144K, 55% used [0x221d0000, 0x22527  E10, 0x227d0000) to space 6144K, 0% used [0x21bd0000, 0x21bd0000, 0x221d0000] tenured generation total 69632K, used 2696K [0x227d0000, 0x26bd0000, 0x26bd0000) The space 69632K, 3% used [0x227d0000, 0x22a720f8, 0x22a72200, 0x26bd0000) CO Mpacting Perm Gen Total 8192K, used 2898K [0x26bd0000, 0x273d0000, 0x2abd0000) The space 8192K, 35% used [0x26bd0000, 0x26ea4ba8, 0X26EA4C00, 0x273d0000) Ro space 8192K, 66% used [0x2abd0000, 0X2B12BCC0, 0x2b12be00, 0x2b3d0000) RW sp Ace 12288K, 46% used [0x2b3d0000, 0x2b972060, 0x2b972200, 0x2bfd0000) 34.735: [defnew:52568k->3433k (55296K), 0.007212 6 secs] 55264k->6615k (124928K) Heap after GC invocations=8:def new generation Total 55296K, used 3433K [0x1ebd0000, 0 x227d0000, 0x227d0000) EdeN Space 49152K, 0% used [0x1ebd0000, 0x1ebd0000, 0x21bd0000) from space 6144K, 55% used [0x21bd0000, 0x21f2a5e8, 0x221 d0000) to space 6144K, 0% used [0x221d0000, 0x221d0000, 0x227d0000] tenured generation total 69632K, used 3182K [0x 227d0000, 0x26bd0000, 0x26bd0000) The space 69632K, 4% used [0x227d0000, 0x22aeb958, 0x22aeba00, 0x26bd0000) compacting P Erm Gen Total 8192K, used 2898K [0x26bd0000, 0x273d0000, 0x2abd0000) The space 8192K, 35% used [0x26bd0000, 0X26EA4BA8 , 0X26EA4C00, 0x273d0000) Ro space 8192K, 66% used [0x2abd0000, 0X2B12BCC0, 0x2b12be00, 0x2b3d0000) RW space 12288K , 46% used [0x2b3d0000, 0x2b972060, 0x2b972200, 0x2bfd0000)}, 0.0757599 Secs]-xloggc:filename: Used in conjunction with the above several, Logs the relevant log information to a file for analysis. Common configuration Rollup heap settings-xms: initial heap size-xmx: Maximum heap size-xx:newsize=n: Set the young generation size-xx:newratio=n: Sets the ratio of the young generation to the old generation. For example: 3, the ratio of the young generation to the old generation is 1:3, the young generation of the entire young generation of the old generation and the 1/4-xx:survivorratio=n: The young generation of the Eden area and two survivor area ratio. Note that there are two survivor districts. such as: 3, represents Eden:survivor=3:2, a Survivor area for the entire young generation of 1/5-xx:maxpermsize=n: Set the persistence generation size collector settings-XX:+USESERIALGC:Set up the serial collector-XX:+USEPARALLELGC: Set the parallel collector-XX:+USEPARALLEDLOLDGC: Set the parallel aging generation collector-XX:+USECONCMARKSWEEPGC: Set the concurrency Collector garbage Collection Statistics-xx:+ Printgc-xx:+printgcdetails-xx:+printgctimestamps-xloggc:filename Parallel collector Settings-xx:parallelgcthreads=n: Sets the number of CPUs to use when the parallel collector is collected. The number of parallel collection threads. -xx:maxgcpausemillis=n: Set maximum pause time for parallel collection-xx:gctimeratio=n: Sets the percentage of garbage collection time that is the program run time. The formula is 1/(1+n) Concurrent collector Set-xx:+cmsincrementalmode: set to incremental mode. Applies to single CPU conditions. -xx:parallelgcthreads=n: Set the concurrency collector the number of CPUs used by the young generation collection method for parallel collection. The number of parallel collection threads. Iv. Tuning summarize the choice of response time preference for younger generation sizes: as large as possible until the minimum response time limit of the system is approached (depending on the actual situation). In such cases, the frequency at which the young generation collects occurs is also minimal. At the same time, reduce the reach of older generations of objects. Throughput-First application: as large as possible, may reach Gbit degree. Because there is no requirement for response time, garbage collection can be done in parallel, generally suitable for applications over 8CPU. Older generation Size Select response Time-first application: Older generations use concurrent collectors, so their size needs to be set carefully, and some parameters, such as concurrency session rate and session duration, are generally considered. If the heap setting is small, it can result in memory fragmentation, high recovery frequency, and application pauses using traditional markup cleanup, and if the heap is large, a longer collection time is required. The most optimized scenario is generally referred to in the following data acquisition: Concurrent garbage collection information persistent generation of concurrent collection times the proportion of traditional GC information spent on the collection of young and old generations reduces the time spent by younger generations and older generations, Typically increases application efficiency throughput priority applications: General throughput priority applications have a large young generation and a smaller old generation. The reason for this is that the majority of short-term objects can be recovered as much as possible, reducing medium-term objects, while older generations store long-lived objects. Fragmentation problems caused by smaller heaps the heap is not compressed because the old generation of concurrent collectors uses tags and clears the algorithm. When the collector recycles, he merges the adjacent space so that it can be assigned to a larger object. However, when the heap space is small, after a period of time, "fragmentation" occurs, if the concurrent collector cannot find enough space, then the concurrent collectionThe collector will stop and then be recycled using traditional marking and purging methods. If "Fragmentation" occurs, you may need to configure the following:-xx:+usecmscompactatfullcollection: When using the concurrency collector, the compression of older generations is turned on. -xx:cmsfullgcsbeforecompaction=0: When the above configuration is on, how many times the full GC is set, the old generation is compressed

"-xmx1024m-xms1024m-xmn512m-xss256k"--java Run parameters

Related Article

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.