For variable problems in Java

Source: Internet
Author: User

A variable of a primitive type, if defined, allocates memory space, regardless of whether it is assigned, or if it is a property of an object, so long as the object is not instantiated, no memory space is allocated. 

A complete Java program will run with the following memory areas:
1, Register: JVM Internal virtual register, access speed is very fast, the program is not controllable.
2, Stack: Save the values of local variables, including:
1) values used to hold the base data type;
2) Save an instance of the class, which is a reference to the heap area object (pointer)
3) can also be used to save the frame when loading the method
3, Heap: Used to store dynamically generated data, such as new out of the object. Note the objects that are created contain only the member variables that belong to them, and do not include member methods. Because objects of the same class have their own member variables,
stored in their own heap, but they share the method of the class, not every object created to copy the member method once.

4. Chang: The JVM maintains a constant pool for each loaded type, and a constant pool is an ordered set of constants used by this type.
includes direct constants (basic types, String) and symbolic references to other types, methods, and fields (1). The data in the pool is accessed through the same index as the array.
because a constant pool contains symbolic references to other types, methods, and fields for one type, Chang plays a central role in the dynamic linking of Java. A constant pool exists in the heap.

5, Code snippet: used to store the source code read from the hard disk.
6. Data segment: Static member that is used to store the static definition.

For variable problems 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.