Java memory management is divided into two areas : memory allocation and memory reclamation. The memory allocation here refers specifically to the JVM when creating Java Objects
The memory space allocated for the object in heap memory. Memory recycling refers to when the Java object loses its reference and becomes garbage,theJVM
Garbage collection mechanism to automatically clean up the object and reclaim the memory that the object occupies.
Because the JVM 's garbage collection mechanism is done by a background thread, it is also very performance-intensive, so if unscrupulous
To create an object that allocates memory, the allocated memory is reclaimed by the garbage collection mechanism.
There are two disadvantages to doing this :
1. constantly allocating memory to reduce the available memory in the system, thus reducing the performance of program Operation ;
2. a large amount of allocated memory recycling makes the burden of garbage collection heavier, reducing the performance of the program .
variables in Java programs can be broadly divided into member variables and local variables. The local variables can be divided into the following 3 classes.
1. Formal parameter : the local variable defined in the method signature, which is assigned by the method caller, dies with the end of the method .
such as public void method (variable type variable name) {} ( variable type variable name) also called formal parameter
2. Local variables within a method : local children defined within a method must be explicitly initialized within the method . This type of local variable takes effect from the completion of initialization and dies with the end of the method. .?
3. Local variables within code blocks : Local variables defined within a block of code that must be explicitly initialized within a block of code . This type of local variable takes effect from the completion of initialization and dies with the end of the code block .?
In the class are member variables, and the member variables are divided into instance variables and class variables. (class variables have static adornments)
Java Fundamentals 10