Java memory area and memory overflow exception

Source: Internet
Author: User

Runtime zones managed by Java (5):

Program counter: (where the current thread bytecode executes, which bytecode to execute, the line number that points to the bytecode)

This can be seen as the line number of the bytecode being executed by the current thread, that is, the exact location of the bytecode used to identify the current thread execution. The bytecode interpreter works by changing the program counter to select the next byte-code instruction to execute.

is thread-private, branch, loop, thread switch, jump, etc. all need to depend on it.

Java Virtual Machine stack: (Information related to method execution, is stack)

Thread-Private;

Each method executes creates a stack frame for storing and executing information about the method, including the local variable table, the operand stack, the method exit, and so on.

Then the execution of each method corresponds to the frame in the stack, the method end corresponds to the frame out of the stack.

Local method Stack:

The stack uses the native method service for the virtual machine (Java calls non-Java code)

Java heap: (Storing objects)

Thread sharing;

The sole purpose of storing object instances;

is the largest chunk of the runtime area managed by the Java Virtual machine.

Method Area:

Areas shared by each thread;

Used to store information such as class information, constants, static variables, etc.;

Run a constant pool: is part of the method area, saving the symbol references described in the class file and the direct references that are translated.

Direct Memory:

Use of the native method to introduce the use of local memory is not limited by the size of the Java heap.

OutOfMemoryError

In addition to the program counters, the other heap or zone throws the exception when it cannot request the required memory.

Java memory area and memory overflow exception

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.