Tiles in a Java virtual machine

Source: Internet
Author: User

The JVM memory palette is divided into 5 chunks: Java heap, permanent generation, stack space, local method stack, Cheap.

Java heap: Also known as the heap area, including the young and old two plates

Permanent generation:,

Stack space: Runtime thread private stack space

Local method Stack: Code area of Part C

CHEAP: Memory usage in non-Java regions, some JNI calls use heap memory


Yong Space is divided into 3 sections: 1 eden+2 survivor areas.

Eden Zone: Objects created using methods such as new () or newinstance () are placed in the Eden area by default (unless the object is too large, the default size threshold is-xx:pretenuresizethreshold, and the threshold value is placed in the old area).

2 Survivor District is also called S0, S1 District. When the Eden area is full, it will do YOUNGGC (also known as MINORGC).


Location Summary:

1. When an object is instantiated, the size of the object does not reach the threshold and is placed in the Eden area.

2. On the first occurrence of MINORGC, an area in S0 or S1 is selected to write the live objects in the Eden area (this is assumed to be S0), and if the S0 area is not placed, the old area is placed, and the Eden area is emptied.

3. When MINORGC occurs the second time, the "live objects in the Eden Zone +s0 area are copied to S1", and if the S1 area does not fit, the object is placed in the old area and then emptied of the Eden and S0 areas.

4, the third occurrence of MINORGC, the "Eden Zone +s1 The living objects in the region copy to S0", if the S0 area is not placed, the object will be placed in the old area, and then empty the Eden area and the S1 area, and so on.


Summary:

1, usually, the FULLGC is we do not want to see the situation. If the write code is a large number of memory in use, it will frequently lead to FULLGC, for example: In a multithreaded system, each request the corresponding thread each more than a few KB or a few megabytes of space, then these extra space will soon be put into the old area, when the old area is full, it will be done to do fully GC operation.

2, when the survivor area is not placed, the object enters the old area, the JVM will check the old area of the memory space is sufficient, if not enough, will do a full GC operation.

3. If a string object is invoked through the Intern () method, the object allocates space in the perm zone's constant-variable pool, which, of course, guarantees a unique value through equals. However, if a large number of intern () methods of the different string objects are called, then these objects will form a copy in the Perm area, gradually causing the perm area to be full, and the area will be FULLGC if it is full. If there is no reference to a string constant when the full GC occurs, the object is recycled and, if there is, it cannot be reclaimed, resulting in an oom.

4, class objects are also stored in the Perm area, if the dynamic loading of a large number of classes, and can not be unloaded, then the Perm area will be full, will naturally FULLGC, Even Oom (note: If any of the following class objects under the relevant ClassLoader are still alive, then it will not be released)

5, the thread of the stack space, this space is the private space of the thread, it will be stored in the process of running the local variable information, advanced after the stack. In the process of running the program, if, recursive calls, constantly consume the stack space, there will be stackoverflowerror errors.

Tiles in a Java virtual machine

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.