Java memory area and memory overflow

Source: Internet
Author: User

The Java memory area can be divided into two main categories:

1, thread-sharing:
Method Area: Thread sharing, which stores data such as class information, constants, static variables, and code compiled by the instant compiler that have been loaded by the virtual machine. It is described as part of the heap by the virtual machine specification. are also considered "permanent generations".

Run constant: Part of the method area;

Heap: So threads are shared; Almost all object instances, arrays are allocated memory on the heap (JIT technology can not allocate memory on the heap, such as stacks), can be physically discontinuous, there may be a thread-private thread buffer assigned to each thread (thread Local
Allocation Buffer, Tlab); The heap traffic is also divided into the primary generation, the elderly generation;

Execution Engine:

Local Interface Library:

Direct Memory: A part of the data area that is not a virtual machine, or an area of memory defined in the Java VM Specification, may also cause memory exceptions, and the memory inside is out-of-heap memory.

2, the thread exclusive:
Virtual machine stack: The life cycle is the same as the thread, where the local variable table holds the underlying type data or the object's reference, and if the thread requests a stack depth that exceeds the depth of the virtual machine's run, Stackovermemoryerror is thrown;

Local method Stack: similar to the virtual machine stack, even some virtual machines do not distinguish between the two.

Program Calculator: The line number indicator of the current thread execution byte code, used by the bytecode interpreter to select the next execution instruction. Consumes little memory and is used only for Java code.

Object Memory Layout:

1. Object: Consists of three parts, object header (header), instance data (Instance), aligned padding (padding)

2. Object Head:
A, a part is used to store its own runtime data, including hash code (25BIT), GC generational age (4bit), lock status Tag (2bit), thread-held lock, biased thread ID, biased time stamp;
B, part of the type pointer, the class metadata that points to it

Java memory area and memory overflow

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.