Java Virtual machine Learning

Source: Internet
Author: User
Tags class definition

Method area, heap, stack, program counter, local method stack
Method Area (permanent): class definition, constants, static variables, memory regions shared by each thread, code for immediate compilation
Heap: Class object, list, array thread sharing area
Stack: program execution is a thread, thread execution is called method, there are (local variables), each thread has its own (thread-private), each method call produces a stack frame, call method is in the stack out of the stack
If the method has been nested calls will always be stacked, there may be stack overflow,
Program counter: Which line the program executes.
Local method Stack: and local platform (operating system) methods to invoke the operating system

garbage collection;
Heap: According to the age of the object survival, is divided into the Cenozoic young Generation, the old age,

Young generation is divided into Eden Space and Survivor (From,to (not used)) area
Garbage collection algorithm Scan Edenspace If there is value left to be placed in the survivor (from) area, after the default 15 times it is left behind and put into oldgegnration

How to recycle,
Mark-Clear if the object is too large to be placed directly in the old age
Mark-Organize
Copy-algorithm (to is used for maneuvers)
You can set the scale of Eden and Suivivor when you start a Java virtual machine.
The old age is as big as the new generation

Garbage Collection Implementation
Garbage collector
Serial collector Stop the World Full volume recycling
Serial Old collector
Parnew Collector
Throughput-First, Parallel scavenger collector

CMS Collector server-side comparison (default)
G1 Recycle Collector
-xx +use Garbage Collection

JAVA-XMX3550M-XMS3550M-XMN2G-XSS128K-XX:NEWRATIO=4-XX:SURVIVORRATIO=4-XX:MAXPERMSIZE=16M-XX: Maxtenuringthreshold=0

-xmx3550m: Maximum heap memory is 3550M.

-xms3550m: Initial heap memory is 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 heap 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, and with the same physical memory, reducing this value can generate more threads. However, the operating system of the number of threads within a process is still limited, can not be generated indefinitely, the empirical value of 3000~5000 around.

-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 younger generation takes up 1/5 of the entire stack.

-xx:survivorratio=4: Sets the ratio of the size of Eden and survivor in the younger generation.

Set to 4, the ratio of two survivor to one Eden area is 2:4, and a survivor area represents 1/6 of the entire young generation.

-XX:MAXPERMSIZE=16M: Set the persistent generation size to 16m.

-XX:MAXTENURINGTHRESHOLD=15: 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.

Collector Settings

-XX:+USESERIALGC: Setting up the serial collector

-XX:+USEPARALLELGC: Setting up a parallel collector

-XX:+USEPARALLEDLOLDGC: Setting up a parallel old generation collector

-XX:+USECONCMARKSWEEPGC: Setting 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 time that garbage collection takes to run the program. The formula is 1/(1+n)

Concurrent collector Settings

-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.

Java Virtual machine Learning

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.