The Java virtual machine specification defines the Java memory model to shield the memory differences of various hardware and operating systems to achieve cross-platform memory access effects.
In order to obtain better execution performance, the Java memory model does not limit the execution engine to use the processor's specific cache or cache to interact with main memory (which can be compared to RAM, but is part of the virtual machine memory), working memory (which can be The analog cache, which is also part of the virtual machine's memory) is private to the thread.
The division of working memory and main memory is different from the division of Java heap, stack, and method area. The two are basically irrelevant. If they barely correspond, the main memory can be understood as the instance data part in the heap, and the working memory corresponds to the part in the stack Area
-----Quote<<In-depth understanding of JAVA virtual machine>>
A thread will have a thread stack, and a method call is a stack frame. A stack frame is divided into: local variable area, operand stack and frame data area. You can understand that working memory is the data in the local variable area.
The definition of cache here is too broad and can easily cause ambiguity. Liz, just look at this
The Java virtual machine specification defines the Java memory model to shield the memory differences of various hardware and operating systems to achieve cross-platform memory access effects.
In order to obtain better execution performance, the Java memory model does not limit the execution engine to use the processor's specific cache or cache to interact with main memory (which can be compared to RAM, but is part of the virtual machine memory), working memory (which can be The analog cache, which is also part of the virtual machine's memory) is private to the thread.
The division of working memory and main memory is different from the division of Java heap, stack, and method area. The two are basically irrelevant. If they barely correspond, the main memory can be understood as the instance data part in the heap, and the working memory corresponds to the part in the stack Area
-----Quote<<In-depth understanding of JAVA virtual machine>>
A thread will have a thread stack, and a method call is a stack frame. A stack frame is divided into: local variable area, operand stack and frame data area.
You can understand that working memory is the data in the local variable area.
@wlingxiao said in "In-depth Understanding of JAVA Virtual Machine", Second Edition, 12.3.1 Main Memory and Working Memory