JVMの研究ノート(b)は、ランタイムデータ領域(実行時のデータの分野)

 

公式サイトのアドレスに対応:ランタイムデータエリア

4.ランタイムデータ領域(ランタイムデータの分野)

クラスファイルをローダにロードされた後、クラス(例えば、変数、定数、メソッド、オブジェクトのような)コンテンツを格納する必要があります。

4.1グラフィック

 

4.2一般的な理解

4.2.1方式エリア(面積法)

メソッド領域は、仮想マシンの起動時に作成された、メモリ領域の種々のスレッドで共有されています。

仮想マシンを格納するためのクラス情報、定数、静的変数、コードやその他のデータをコンパイルする時コンパイラにロードされています。

 

重点

  • メソッド領域でJDK8メタスペース、JDK7はパーマスペースです

  • ランタイム定数プールは、独立変数とコンパイル時生成された基準シンボルのさまざまなを格納するために使用される、この部分は、ゾーンの時定数・ストレージ・プールロードされたクラスのメソッドで実行するようになっています。

Each run-time constant pool is allocated from the Java Virtual Machine's method area (§2.5.4).

定数プールは、メモリが不足して報告されますOutOfMemoryError

When creating a class or interface, if the construction of the run-time constant pool requires more memory than can be made available in the method area of the Java Virtual Machine, the Java Virtual Machine throws an OutOfMemoryError.

ステップクラスローディング:このバイトストリームランタイムデータ構造領域法に静的記憶構造を表します。

 

 

4.2.2ヒープ(ヒープ)

JavaのJava仮想マシンのヒープメモリの最大ブロックで管理されている仮想マシンが起動したときに、作成されたすべてのスレッドで共有されます

Javaオブジェクト・インスタンスと配列ペアに割り当てられます

The Java Virtual Machine has a heap that is shared among all Java Virtual Machine threads. The heap is the run-time data area from which memory for all class instances and arrays is allocated.

 

ローディングステージ型の第三段階:このクラスの表現のJavaヒープを生成しjava.lang.Classたオブジェクトを、そのようなデータの入口領域へのアクセスの方法として

 

4.2.3 Java仮想マシンスタック(VMスタック)

各スレッドは、JVM仮想マシンのスタックを持っています。

Javaスレッドの実行状態がスタックから仮想マシンを保持するために、仮想マシンの作成とスタックは、スレッドを作成しました

各方法は、スタックのために、実行のスレッドであるスタックフレームのスタックフレームの各々に対応する、すなわち方法。

メソッドを呼び出して、スタックはスタックフレームにプッシュされます。メソッドの呼び出しが終了し、フレームはスタックからスタックをポップされます。

内部データスタックの原則:最後のうち、最初のうちで最後。

Each Java Virtual Machine thread has a private Java Virtual Machine stack, created at the same time as the thread.

イラスト

 

4.2.4 PCレジスタ(プログラムカウンタ)

程序计数器占用的内存空间很小,由于 Java虚拟机的多线程是通过线程轮流切换,并分配处理器执行时间的方式实现的,在任意时刻,一个处理器只会执行一条线程中的指令。

因此,为了线程切换后能够恢复到正确的位置,每条线程都需要一个独立的程序计数器(线程私有)。

线程执行java方法,则计数器记录的是 正在执行虚拟机字节码指令的地址;

线程执行native方法,则计数器为空。

The Java Virtual Machine can support many threads of execution at once (JLS §17). Each Java Virtual Machine thread has its own pc (program counter) register. At any point, each Java Virtual Machine thread is executing the code of a single method, namely the current method (§2.6) for that thread. If that method is not native, the pc register contains the address of the Java Virtual Machine instruction currently being executed. If the method currently being executed by the thread is native, the value of the Java Virtual Machine's pc register is undefined. The Java Virtual Machine's pc register is wide enough to hold a returnAddress or a native pointer on the specific platform.

 

4.2.5 Native Method Stacks( 本地方法栈)

如果当前线程执行的方法是 Native 类型,这些方法就会在本地方法栈中之心


When I let go of what I am , I become what I might be.
走出舒适圈,遇见更好的自己。

发布了91 篇原创文章 · 获赞 63 · 访问量 18万+

おすすめ

転載: blog.csdn.net/qq_38423105/article/details/104710208