Java can be widely used, it is very important that the GC (garbage Collection, garbage collection) mechanism, Java and C + + is one of the main differences. The benefit of the GC mechanism is that we do not need to focus too much on the oom caused by memory leaks, but this does not mean that there is no memory leak in Java development, and in some cases the GC can also affect the efficiency of the program, which in extreme cases causes "the whole world to be still."
Java GC, designed to memory management. The memory area of Java
1. Procedure counter (program Counter Register) area
This area is relatively small and records where the current Java thread bytecode is executed. It is a thread-private (a thread that associates a program counter).
2. Virtual machine stack (JVM stack) zone
Advanced out of the data area, store Java local variables, operands, method exports, etc., is also thread-private
3. Local methods Stack (Native method Stack) area
That is, the stack used to execute the local code, the thread private
4. Heap Area
The most important area of Java GC, where Java object instance data is generated and destroyed, belongs to all threads
5. Method area
Used to store the class information that has been loaded by the virtual machine (that is, the information that needs to be loaded when the class is loaded, including the version, field, method, interface, and so on), the final constant, the static variable, the compiler's immediately compiled code, and so on. belongs to all threads
Java Memory Partitioning