JVM memory diagram (easy to understand)

JVM memory map

Insert picture description here

Heap

The sole purpose of this memory area is to store object instances, and almost all object instances allocate memory here.
Described in the JVM virtual machine specification:All object instances and arraysMust be allocated on the heap.

Stack (Virtual Machine Stack)

For storageLocal variableWait.After the method is executed, it will be released automatically

Method Area

For storageClass information, constants, and static variables loaded by the virtual machineJust-in-time compiler compiled codeAnd other data.


An object memory graph

Insert picture description here

Three object memory graph

3 objects, of which two references point to the same object
Insert picture description here

Guess you like

Origin blog.csdn.net/AC_872767407/article/details/113408256