What is a GC? Why do we have a GC
A: GC is the meaning of garbage collection (Gabage Collection), memory processing is where programmers are prone to problems,
Forgotten or faulty memory recycling can cause a program or system to become unstable or even crash, and the GC functionality provided by Java automatically
If the object exceeds the scope to automatically reclaim memory, the Java language does not provide free allocated memory
The display action method.
--------------------------------------------------------
What is the rationale behind the garbage collector? Can the garbage collector reclaim memory right away? What is the way to proactively notify a virtual machine for garbage collection
A: For GC, when a programmer creates an object, the GC starts to monitor the address, size, and usage of the object. Typically, GC uses
All objects in the heap are recorded and managed in a map-to-graph manner. In this way, you determine which objects are "accessible" and which objects are "unreachable."
When the GC determines that some objects are unreachable, it is the responsibility of the GC to reclaim those memory spaces. OK. Programmers can manually execute System.GC (),
Notifies the GC to run, but the Java language specification does not guarantee that the GC will execute.
Java garbage collection mechanism