Java Memory allocation

Source: Internet
Author: User

JVM Memory Area Model:

* Program counter, Memory area is very small, is the current thread bytecode execution line number indicator;

* The virtual machine stack, The local method stack, which is usually referred to as the "stack", is the virtual machine used to execute methods (including java, Non-java methods), The use of temporary memory space to store the current method, local variables, and so on, all basic type variables, as well as the class object references are stored in the stack;

* Method area, Global shared zone, used to store class information that has been loaded by the virtual machine, constants (such As string literal constants), static variables, and compiler-compiled code;

* heap, the largest chunk of memory in Java Virtual machine management, shared by all threads, used to store all Java class Instances. Note that the instance data opens up memory in the heap, and the reference to the object is equivalent to a pointer stored in the stack of THREADS.

Create an Object

  Person Person1=new person ("John", 20);

1. The person person1=null in the stack memory;

2. New person in heap memory ("John", 20);

3 initialization, The Person1 reference pointer (pointer in the Stack) points to the new person in heap memory ("John", 20);

==================================================

http://blog.csdn.net/yangyuankp/article/details/7651251

Java Memory allocation

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.