The Java program executes the memory processing process

Source: Internet
Author: User

We learn knowledge, not only to know it, but also to know why, your wages must be proportional to the depth of your study.

In the past. NET learning process, we understand how to develop a program, and have a certain degree of development experience, but a program specifically how to run in memory?

1, first look at a picture.

2, in this picture, we can clearly understand:

    • Local variables are mainly stored in the stack.
    • The heap stores new things.
    • Static variables or string constants exist in data segment.
    • The method in the class, then, is in code segment.

3. Example

Give a simple Java code example to everyone to deepen their understanding

 Public Static void Main (String args[]) {         new Point (1, 2, 3);} class point{    int  x, y, Z; Point (intint int _z)        = _x;     = _y;     = _z;  }

This procedure is run as follows:

    1. Load the program from the hard disk into the memory area
    2. Find the Main method to start execution
    3. Memory management during execution of programs

The local variable p appears in the stack memory;

The data area appears in the heap memory;

The pointer to p in the stack points to the corresponding data area in the heap.



The Java program executes the memory processing process

Related Article

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.