Simple understanding of JAVA memory partition

Java's memory is divided into five parts

So what are the five parts? Follow me down!

Introduction: each program needs memory space to run, so Java is no exception; Java divides this piece of memory applied from the computer! The purpose is to make the program run and process better!

First block:

Part I

"Stack" - (stack)

1. It stores the local variables in the method.

2. The "local variable" refers to the parameter of the method or the variable inside the braces {}.

3. One feature of this "local variable" is "scope".

4. Once the "scope" (braces) is exceeded, it will disappear from the stack memory immediately.

5. The method must be executed in the stack.

Second block:

Part II

Heap

1. All new things are in the pile.

2. Everything in the heap memory has an address value: a hexadecimal value.

3. In addition, the data in the heap memory has default values. The rules are as follows:

If it is an integer - 0 by default;

If it is a floating point number - the default value is 0.0;

If it is character type - the default is' \ u0000 ';

If it is a Boolean class - false by default;

If it is a reference type - null by default;

Block 3:

Part III

"Method area" -- Method area

1. Storage Class, including method information.

Fourth piece

Part IV

"Local method stack" -- native method stack

1. It is related to the operating system.

Fifth piece

Part V

"Register" - PC register

1. CPU related

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>