Java Essentials components that need to use memory in Java

Source: Internet
Author: User
Tags xms

When a Java program starts running as a process in the operating system, what parts of the process need to allocate memory?

1 Java Heap

The Java heap is used to store Java objects, and the size of the heap is applied to the operating system once at the start of the JVM, using-XMX and-XMS to control the size. Where xmx represents the maximum value of the heap, XMS represents the initial value of the heap. Once the allocation is complete, the heap size is fixed and cannot be re-applied to the operating system when memory is insufficient, and the extra space cannot be returned to the operating system when memory is idle.

2 Threads

The entity on which the JVM runs the actual program is a thread, and the thread needs memory to store the data. Each time a thread is created, the JVM creates a stack for it, and the size of the stack differs depending on the JVM implementation.

Class 3 and Class loaders

Classes and class loaders are stored in the heap, which is called a permanent generation (PermGen zone). The JVM loads classes on demand and loads only one class into memory at a time.

4 NIO

jdk1.4 later introduced a new way of performing I/O based on channel and buffer NiO, using the Java.nio.ByteBuffer.allocateDirect () method to allocate native memory instead of memory on the Java heap.

5 JNI

JNI enables native code, such as a C language program, to invoke a Java method. In fact, the Java runtime itself relies on JNI to implement class library functionality, so JNI increases the native memory footprint of the Java runtime.

Resources

In-depth analysis of Java Web Technology Insider p201-203

Java Essentials components that need to use memory in Java

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.