At the same time, it is necessary to clarify that Java memory is roughly divided into: virtual machine stack, Native method stack, Java heap, local program counter and method area. A HashMap reference can be used as a GC Root, but the HashMap entity is not a GC Root.
GC Roots include:
Variables in the virtual machine stack.
Constants in the method area.
Static variables in the method area.
At the same time, it is necessary to clarify that Java memory is roughly divided into: virtual machine stack, Native method stack, Java heap, local program counter and method area. A HashMap reference can be used as a GC Root, but the HashMap entity is not a GC Root.