JVM-terms to be known

Source: Internet
Author: User

1. Distribution of generations in the Java heap:

YOUNG: Mainly used to store new objects.

Old: Mainly stores memory objects with long life cycles in applications.

Permanent: indicates the permanent storage area of the memory, which stores information about the class and Meta. When the class is loaded, it is placed in the permgen space area. unlike the heap region where the instance is stored, GC (garbage collection) does not clean up permgen space during the main program running, so if your app loads a lot of classes, the permgen space error may occur.

 

2. What is the GC algorithm used by JVM?

Generation-based collection.

The memory is divided into several regions, and objects of different lifecycles are placed in different regions;

During GC collection, young areas with short lifecycles are frequently collected );

A small area with a long collection lifecycle (old area );

Perm area ).

3. What is the difference between GC and full GC?

GC (or minor GC): the young area that collects short lifecycles ).

Full GC (or major GC): collects garbage from the entire heap in the young area and the old area with a long life cycle.

Their collection algorithms are different, so the time used varies. GC efficiency is also relatively high. We should minimize the number of full GC times. When system. GC () is called, GC does a full collection (both young generation and tenured generation ).

4. After minor GC, is Eden empty?

Yes, minor GC will move all the live objects in Eden to the same vor region. If the remaining live objects cannot be placed in the same region, they will be moved to the old generation.

5. Garbage collection options (jdk1.4 ):

 

 

Heap settings
-XMS: initial heap size
-Xmx: Maximum heap size
-XX: newsize = N: Set the young generation size
-XX: newratio = N: Ratio of the young generation to the old generation. For example, if the value is 3, the ratio of the young generation to the old generation is. The young generation accounts for 1/4 of the young generation and the old generation.
-XX: Ratio vorratio = N: Ratio of the Eden zone in the young generation to the two region vor zones. Note that there are two vor zones. For example, 3 indicates EDEN: Primary vor =. One primary vor zone accounts for 1/5 of the young generation.
-XX: maxpermsize = N: sets the persistent generation size.
Collector settings
-XX: + useserialgc: sets the serial collector.
-XX: + useparallelgc: set parallel collectors
-XX: + useparalledloldgc: sets the parallel elder generation collector.
-XX: + useconcmarksweepgc: sets the concurrent collector.
Garbage collection statistics
-XX: + printheapatgc heap details
-XX: + printgcdetails GC details
-XX: + printgctimestamps: Print GC time information
-XX: + printtenuringdistribution: Print age information, etc.-XX: + handlepromotionfailure old-age allocation guarantee (true or false) Parallel collector settings
-XX: parallelgcthreads = N: set the number of CPUs used for parallel collector collection. Number of parallel collection threads.
-XX: maxgcpausemillis = N: sets the maximum pause time for parallel collection.
-XX: gctimeratio = N: Set the percentage of the garbage collection time to the running time. The formula is 1/(1 + n)
Concurrent collector settings
-XX: + cmsincrementalmode: Set to incremental mode. Applicable to a single CPU.
-XX: parallelgcthreads = N: set the number of CPUs used when the concurrent collector is used for collecting data in parallel in the young generation. Number of parallel collection threads.

6. JVM runtime data area (runtime data area ):

 

Heap: The JVM only has one heap shared by all threads. All class instances and arrays are created in the heap.

Method Area: The JVM only has one method area shared by all threads. It stores class structures, such as runtime constant pool, member and method data, and Code of methods and constructor methods.

Java stacks: Each JVM thread has a private stack.

PC registers: JVM supports running multiple threads at the same time. Therefore, each thread needs its own PC (program counter) Register.

Native method stacks: the address for saving the native method to enter the region.

7. Log Analysis

GC (minor) logs

Full GC log

 

JVM-terms to be known

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.