Java Virtual Machine of the stack

A program counter (register): PCR

Role: Remember JVM execution address of the next instruction.

Features: ① ② thread private memory overflow does not exist

II. VM stack

1. Definitions

Virtual machine stack: the thread needs to run the memory space.

Stack frame: a stack frame corresponds to a method invocation.

Each thread can only have one active stack frame, which corresponds to the method currently executing.

Thinking:

First, whether it comes to garbage collection stack memory? : No, stack memory is a time of method invocation stack frame memory, once the method call will pop the stack, it will be automatically recovered off, so there is no need to manage the stack memory garbage collection, garbage collection just recovered the heap of useless objects.

Second, the stack memory allocation bigger the better it? : No, some physical memory, the greater the stack memory, will reduce the number of threads, the more memory the stack just adds multiple recursive calls, you can generally use the default size.

Third, whether local variables within the method thread safe? : The method of local variables within the scope not escape the method, it is safe, and vice versa.

2. Stack memory overflow

Overflow: ① ② stack frame stack frame too large

3. Thread run diagnostics

 

 Third, the native method stacks

clone

Guess you like

Origin www.cnblogs.com/sadfoo/p/11954205.html