Deep understanding of Java Virtual Machine--java memory area and memory overflow exception

Source: Internet
Author: User

    • Program Counter Register: A small amount of memory space that can be seen as the line number indicator of the byte code executed by the current thread. The bytecode interpreter works by changing the value of this counter to select the next byte-code instruction that needs to be executed, such as branching, looping, jumping, exception handling, thread recovery, and other basic functions that rely on this counter to complete. The multithreading of the Java Virtual machine is realized by the thread rotating and allocating the processor execution time, in order to recover to the correct execution position after the thread switch, each thread has a separate program counter, each thread's program counter does not affect each other, independent storage, this kind of memory area is called "Thread private" of memory. When the thread is executing a Java method that logs the address of the virtual machine bytecode being executed, the counter value is empty when the native method is being executed.

    • Java Virtual machine stack (Java Stacks): The memory model executed by the Java method is thread-private and has the same life cycle as the thread. Each method executes while creating a stack frame that stores information such as local variable tables, operand stacks, dynamic links, method exits, and so on. Each method moves from the call to the completion of the execution of a stack frame in the virtual machine stack into the stack to the process.

    • Local method Stack: The Native is very similar to the virtual machine stack, except that the virtual machine stack executes the Java Method (bytecode) service for the virtual machine, while the local method stack serves the Native method used by the virtual machine.

    • Java Heap (Java heap): A chunk of memory shared by all threads, with all object instances and arrays allocated on the heap. The Java heap is the primary area of garbage collector management and is therefore also known as the GC heap (garbage collected heap)

    • Method Area: Like the Java heap, is a region of memory shared by each thread that stores data such as class information, constants, static variables, and code compiled by the immediate compiler that have been loaded by the virtual machine.

    • Run a constant pool (runtime Constant Pool): A part of the method area, where the class is loaded, and it is used to hold various literal and symbolic references generated by the compilation period.

Deep understanding of Java Virtual Machine--java memory area and memory overflow exception

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.