The memory structure of the Java Virtual machine

Source: Internet
Author: User

1) stackstack memory: Used to run the thread, including temporary data in the method, storing the local variables that the thread is running, and the object's reference



1, the memory structure of the Java virtual machine

1) Heap heap Memory: an instance of an object

2) Non heap non-heap Memory: Method Area: Run constant value and static method.

For example:person p = new Person();

P This variable is a reference to the object that exists in the stack , and the new Person() is an instance of an object that exists in the heap.

2, Java 's memory model:heap and Perm(permanent generation) .

1)heap :Eden Cenozoic (minor GC new generation of garbage collection) + old memory aged generation (major GC old generation garbage collector).

2)heap : -xms minimum , -xmx maximum. -xmn The size of the young generation

3)perm:-xx:permsize min., -xx:maxpermsize maximum value.

3, Young generation: The newly created objects are in the younger generation.

Features:minor GC execution is fast and basically does not see the application thread stop.

4, old age: When an object is minor GC multiple garbage collection, when it is not collected back, the object will be transferred to the old generation.

Major GC: When older generations of memory are full, garbage collection starts,Major GC takes a long time, and the application thread stops all when it executes (stop the World).

because the major GC examines all surviving objects, it takes longer and should reduce the execution of the major GC because it causes your application to be unresponsive during major GC garbage collection. So if you have an app that needs a quick response to send multiple major GC , a time-out error may occur.

5, garbage collection time depends on the garbage collection policy. This is why it is necessary to monitor and tune garbage collection so that the JVM does not execute major GC .

6, Permanent generation: Contains the application metadata required by Java, and the permanent generation is not part of the Java heap memory. Contains classes and methods for the Java SE library. Stores the classes used by the JVM runtime . The object of a permanent generation is garbage collection when full GC is in progress. For example, ajar package.

7, JVM Performance tuning:

Set java_opts=-xms=1024m–xmx=1024 .....

-XMS: in a production environment,-XMS and -xmx are best set to the same size, and the benefit is that you can reduce the frequency of the minor GC.

-XMX:

-xmn: The Cenozoic size is generally 30% or 40% of the-XMS.

-xx:permsize: Basically look at the size of the project, the project is particularly large jar packages,Tomcat running multiple jar projects, this time need to increase this value. because when the service starts, all class classes are loaded in.

-xx:maxpermsize


The memory structure of the 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.