Java Web in-depth analysis (one-by-one) JVM (1)

Source: Internet
Author: User
Tags java web

Objective

After Java is started as a process running in the operating system, the process has to allocate the following memory:

1. Java Heap:

Stores the Java memory area, where the heap size is when the JVM starts up as if the operating system request is complete, where-xmx and-xms represent the maximum and initial sizes, respectively. GC management that is fixed and belongs to Java after the heap size allocation is complete.

2. Threads:

The entity of the actual program that the JVM runs is a thread, and the JVM allocates a stack size for it when it creates the thread. If the number of threads is greater than the number of cores in the CPU, it can result in high memory and inefficiency.

3. Class and ClassLoader: The class and ClassLoader are saved in the heap's permanent generation, and they themselves need to occupy memory. 4. NIO:

The NIO class library appears behind java1.4, a new way to execute IO based on channels and buffers, mainly using the Java.io.ByteFuffer Allocatedirect () method to allocate memory. Unlike traditional IO, this way the data interaction of the network or disk directly occurs directly in the kernel space of the operating system, eliminating the time-consuming of copying to JVM space and switching on the Java heap.

5. JNI:

Java native language invocation, in fact, the Java runtime, such as file, network, IO or other hardware calls need to use JNI, so JNI also need to occupy memory.

JVM Memory Structure
    • Line number indicator for PC register (thread private) thread execution
    • Memory model of Java Virtual machine stack (thread private) Java method execution
    • Java heap (thread sharing) garbage heap
    • Method area (thread sharing, permanent generation), class information, constants, static variables, compiled code and other data, the logical part of the heap in the virtual machine specification, alias Non-heap (non-heap) to differentiate
    • The local method area (native method) executes the native method service for the JVM
    • Run a constant pool (literal symbol) PS: Understand the next String.inter () method
allocation, layout, and access of objects above the Java heap 1, creation of objects (in the case of ordinary Java objects)

Java Web in-depth analysis (one-by-one) JVM (1)

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.