In-depth understanding of java virtual machine --- java virtual machine memory management (6)

Understanding of java virtual machine stack

The virtual machine stack is what we know as stack memory. The stack memory is unique to the thread. The reference type stored in the local variable table in the stack memory is only the memory address where the object is stored. The object is created in the heap memory, that is, the object in the thread shared area.

Local variable table: The memory space of the local variable table is allocated at compile time, and is used to store various basic data types, reference types and returnAdress types known during compilation. It is the stack memory that we know well.

Simulate stack overflow

 When a method is called in an infinite loop in a thread, because the execution of the method will allocate a fixed size of memory in the frame, the method will be called continuously (the previous method has not been executed and popped out of the stack), and it will continue in the frame. Create fixed size memory. This will result in

The stackOverFlowError error is reported. If the stack memory size of each thread is not limited, then when the stack cannot request memory from the virtual machine, an error outMemoryError will be reported. The simulation code is as follows:

Stack Overflow Explanation:

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325172409&siteId=291194637