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:
- Load the program from the hard disk into the memory area
- Find the Main method to start execution
- 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