Java Virtual Machine

Source: Internet
Author: User

# Java Virtual machine  ## Java Virtual Machine Overview and basic Concepts  ### class loading subsystem, method area, Java heap, direct memory, Java stack, local method stack, garbage collection system, PC register, execution engine  + Class Loading subsystem: is responsible for loading class information from the file system or network, and the loaded information is stored in a memory space called the method area. + Method Area: is the storage class information, constant information, constant pool information, including the string surface amount and numeric constants. + Java heap: Build Java heap when Java Virtual machine starts, he is the main memory working area of Java program, almost all object instances are stored in Java heap, heap space is shared by all threads. + Direct Memory: Java's NIO library allows Java programs to use direct memory to improve performance, often directly memory speeds better than the Java heap. Applications that are frequently read and written may be considered for use. + Each virtual machine thread will have a private stack, and a thread's Java stack is created when it is created, and the Java stack holds local variables, method parameters, simultaneous Java method calls, return values, and so on. + The Local method stack is very similar to the Java stack, and the maximum difference is that the local method stack is used for local method calls. Java virtual machines allow Java to invoke native methods directly (usually written in C). + Garbage collection system is the core of Java, is also essential, Java has its own garbage cleanup mechanism, developers do not need to manually clean up. + PC (program Counter) Register is also a private space per thread, Java Virtual opportunity to create a PC register for each thread, at any time, a Java thread is always executing a method, this method is called the current method, if the current method is not the local method, the PC The register executes the instruction currently being executed, and if it is a local method, the PC register value is undefined, and the register holds information such as the current execution environment pointer, the program counter, the action stack pointer, the calculated variable pointer, and so on. + The core component of the virtual machine is the execution engine, which executes the bytecode of the virtual machine, which is usually compiled into machine code.  ### heap, stack, method area concepts and linkages   heap solves the problem of data storage, that is, where the data is put, where the   stack solution is running, how the program executes, or how the data is processed   The method area is the fast permanent zone of the secondary stack (Perm) , resolving stack information generation is a prerequisite.  ! [Mark] (HTTP://OUMK5FHGP.BKT.CLOUDDN.COM/BLOG/170813/dcfe6fe48m.png?imageslim)   class information is stored in the method area,  ### Java heap  **java Heap * * is the memory space that is most closely related to the **java application. Almost all of the objects are stored in it, and the Java heap is fully automated, and the garbage collection mechanism automatically cleans up and does not need to be displayed for release.   Depending on the garbage collection mechanism, the Java heap may have different structures, most commonly dividing the entire heap into new generation * * and * * * * * * * *. The new generation holds the object of the newborn or the age object, and the old age object. The   Cenozoic is divided into Eden, S0, S1, S0 and S1, also known as the From and to regions. They are two * * * * * * * * * * * * * * * * * * * * * * * * interchangeable characters.   The vast majority of cases, the object * * * First allocated in the **eden area * *, after a new generation of recovery, if the * * object is still alive * *, will enter the **s0 area or the S1 area * *, after not a cenozoic recovery, if the object survived its age is added 1, When the object reaches a certain age, it enters the old age.  ! [Mark] (Http://oumk5fhgp.bkt.clouddn.com/blog/170813/m5kLdGdeIb.png?imageslim)     has a lot of garbage collectors, GC. For GC garbage collection, for the new generation will be frequent garbage collection, for the old age will also experience recycling,  ### Java stack  java stack is a * * Thread private * * memory space * *, a stack, generally composed of three parts, local variable table, operand stack, Frame data area.  ** local Variable Table * *: Parameters for error function and local variable  ** operand stack * *: Mainly save the intermediate result of the calculation process, as well as the temporary storage space of variables in the calculation process.  ** Frame Data Area * *: In addition to the local variable table and the operand stack, the stack also needs some data to support the resolution of the constant pool, where the frame data area holds a pointer to the constant pool, convenient program access to the constant pool. In addition, when a function returns or an exception occurs, the virtual machine must have an exception handling table to find the exception code when sending the exception, so the exception handling table is also part of the frame data area.  ### Java Method Area  java method area and heap, the method area is a piece of all * * thread sharing * * Memory Area * *, he saved the system's class information, thansuch as the fields, methods, Chang, etc. of the class. The size of the method area determines how many classes the system can hold, and if the system defines too many classes, causing the method area to overflow, the virtual machine also throws a memory overflow error. The method area can be understood as a permanent zone (Perm).         by the number of garbage collection, to analogy garbage collection for the new generation of background old age   just materialized, the initial data of the accident   EDEN S1 and S0 Also known as the From and to zones, they are two spaces of equal size and can transform roles    ## heap, stack, method area  ## virtual machine parameter  ## garbage collection

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.