2016021801-java Memory Area Learning notes

Source: Internet
Author: User

Learn to summarize your learning notes according to the deep understanding of Java virtual machines

  

Program counter

  Purpose : The line number indicator of the current thread's bytecode file. ( the current airport is responsible for the control of aircraft landing air controllers; When the front line represents the current airport,

The byte code executed is equal to the plane that is waiting to be allowed to land, and the line number indicator is equivalent to the air operator who has allowed the landing order.

  Thread Private ( each airport has its own air-control staff, the air-control at different airports independent of each other, do not affect each other)

  analogy : An air operator (line number indicator) of an airport (thread) that is responsible for controlling the landing of a flight (the byte code being executed);

Each airport has its own air-control staff;

exception : No. (The airport has no aircraft landing, the aircraft landing process failure, and the air operator does not have any relationship )

Virtual Machine Stack

  Purpose : Each Java method creates a frame stack at execution time to store information such as local variable tables, method exits, and so on.

Each method from the call to the completion of the process of the corresponding frame stack in the virtual machine stack into the stack to the process;

thread Private .

analogy : A virtual machine stack is like a five-star hotel kitchen, and each method is a gourmet meal done in the hotel kitchen.

exception : The stack depth of a thread request is greater than the allowed depth of the virtual machine stack, which throws a Stackoverflowerror exception;

If the virtual machine stack can be dynamically extended, the OutOfMemoryError exception is thrown if the extension cannot request enough memory.

  

Local variable tables hold various basic data types at compile time, object references, and return address types. The memory space required for the local variable table is allocated at compile time.

When entering a method, the space in the method that requires the frame stack to be allocated to the local variable table is fully deterministic, and the runtime does not change the local variable table size.

Local method Stack

  Purpose : The local method stack serves the local method used by the virtual machine;

The virtual machine stack is a Java method service used by the virtual machine.

thread Private .

  analogy : The virtual machine stack is a five-star hotel (Java Virtual machine) kitchen, the local method stack is the local hotel (operating system) of the kitchen.

  exception : Same as virtual machine stack exception.

Heaps (heap)

  Purpose : All object instances and arrays are allocated on the heap, and the heap is the primary area managed by the garbage collector.

(often said Java memory area is divided into stacks and heaps, then the heap is referred to as the heap)

  thread sharing ;

  analogy : a residential building in a city;

  exception : If there is no memory in the pair to complete the instance assignment, and the heap can no longer be expanded, the OutOfMemoryError exception will be thrown!

Method area

  Purpose : Stores information about classes that have been loaded by virtual machines, constants, static variables, immediately compiled code, and so on.

Method Area Memory recycling is mainly for the recovery of constant pool and the unloading of the type;

  Thread sharing

  Exception : The method area is unable to allocate memory and throws a OutOfMemoryError exception.

Run a constant-rate pool,

  present : The run-time constant pool is part of the method area, except the class file's version, field, method, interface, and constant pool.

  purpose : for storing literal and symbolic references generated at compile time and run time.

  exception : A OutOfMemoryError exception is thrown when a constant pool cannot request memory.

2016021801-java Memory Area Learning notes

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.