JP2009199391A - Garbage collection method, and its execution device, and processing program - Google Patents
Garbage collection method, and its execution device, and processing program Download PDFInfo
- Publication number
- JP2009199391A JP2009199391A JP2008040926A JP2008040926A JP2009199391A JP 2009199391 A JP2009199391 A JP 2009199391A JP 2008040926 A JP2008040926 A JP 2008040926A JP 2008040926 A JP2008040926 A JP 2008040926A JP 2009199391 A JP2009199391 A JP 2009199391A
- Authority
- JP
- Japan
- Prior art keywords
- heap area
- area
- garbage collection
- program
- java heap
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Abstract
Description
本発明は言語処理システムにおいてメモリに記憶されているオブジェクトのガーベージコレクションに関するものである。 The present invention relates to garbage collection of objects stored in a memory in a language processing system.
言語処理システムにおいてメモリ上のヒープ領域に記憶されているオブジェクトの暗黙的な解放手段としてガーベージコレクション(以後、GCと呼ぶ)がある。GCはヒープ領域にあるオブジェクトをその時点で使用することができるか(以後、生存していると呼ぶ)を判別し、生存していないと判断したオブジェクトをヒープ領域から解放する。GCには様々な手法があり、それぞれの手法について長所が存在する。 Garbage collection (hereinafter referred to as GC) is a means for implicitly releasing objects stored in a heap area in a memory in a language processing system. The GC determines whether an object in the heap area can be used at that time (hereinafter referred to as alive), and releases the object that is determined not to be alive from the heap area. There are various GC methods, and each method has its advantages.
GCの手法の1つにStop&Copy方式がある。この方式ではプログラムの実行を止め、プログラムが参照を辿ることができる元(以後、参照ルートと呼ぶ)から辿ることができた(生存している)オブジェクトを元のヒープ領域から別に用意したヒープ領域にコピーする。そのコピーしたオブジェクトから辿ることのできるオブジェクトを更に同じ別の領域にコピーする。これを繰り返すことによって、生存しているオブジェクトのみを別の領域にコピーし、元のヒープ領域全体を生存していないオブジェクトごと破棄し、プログラムは別の領域をヒープ領域として実行を続ける。 One of the GC methods is the Stop & Copy method. In this method, the execution of the program is stopped, and the heap area prepared separately from the original heap area that can be traced from the source from which the program can trace the reference (hereinafter referred to as the reference route) To copy. The object that can be traced from the copied object is further copied to another same area. By repeating this, only the surviving objects are copied to another area, the entire original heap area is discarded together with the non-living objects, and the program continues to execute using the other area as a heap area.
他の手法の1つにMark&Sweep方式がある。この方式ではプログラムの実行を止め、参照ルートから辿ることができる全てのオブジェクトに印を付け(マークする)、その後に印の付かなかったオブジェクトを破棄する(スイープする)。 One of the other methods is the Mark & Sweep method. In this method, execution of the program is stopped, all objects that can be traced from the reference route are marked (marked), and then objects that are not marked are discarded (swept).
この2つの方式はMark&Sweep方式の方がGC実行時間で優れており、Stop&Copy方式の方が新しいデータをメモリに割り付けるのが速いという長所を持っている(非特許文献1)。 These two methods have the advantage that the Mark & Sweep method is superior in GC execution time, and the Stop & Copy method is faster in assigning new data to the memory (Non-patent Document 1).
言語処理システムの1つであるJava(TM)仮想マシン(以後、JavaVMと呼ぶ)(Java及び全てのJava関連の商標及びロゴは、米国及びその他の国における米国Sun Microsystems,Inc.の商標または登録商標である)においてはMark&Sweep方式とStop&Copy方式の2つを組み合わせた世代別GCを採用している(特許文献1)。この方式はStop&Copy方式とMark&Sweep方式の長所を組み合わせたものであり、ヒープ領域を2分割しオブジェクトの生存期間が短いものを片方の領域に置きStop&Copy方式でGCを行い、生存期間が長いものをもう片方の領域に置きMark&Sweep方式でGCを行う。生存期間が短いオブジェクトを扱う領域はStop&Copy方式が向いており、生存期間が長いオブジェクトが多くある領域に対してはMark&Sweep方式を適用する。 Java (TM) Virtual Machine (hereinafter referred to as JavaVM), one of the language processing systems (Java and all Java-related trademarks and logos are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries) Is a generational GC that combines the Mark & Sweep method and the Stop & Copy method (Patent Document 1). This method combines the advantages of the Stop & Copy method and the Mark & Sweep method. Divide the heap area into two, place the object with a short lifetime in one area, perform the GC with the Stop & Copy method, and add the one with the long lifetime. Place in one area and perform GC with Mark & Sweep method. The Stop & Copy method is suitable for areas that handle objects with a short lifetime, and the Mark & Sweep method is applied to areas that have many objects with a long lifetime.
特許文献1に記載のようにGCの実行時間の改善は研究されているが、GCの実行の際に発生するプログラムの停止という問題は依然として発生している。このプログラムの停止時間を発生させずに行う手法についても研究はされてはいるが、プログラムの完全な停止を防ぐことは難しく、またオーバーヘッドも大きい。特許文献2においてはStop&Copy方式において、プログラムとGCの並列実行に対して発生するオーバーヘッドを低減する技術を挙げている。しかしながら、プログラムの完全な停止は依然として存在する。
Although improvement of GC execution time has been studied as described in
GCによってオブジェクトを解放する処理では一般的にはプログラムの実行が停止される。これはGCの処理によってヒープ領域の状態が変化する為、同じくヒープ領域の状態を変化させるプログラムの実行と並列に行うことは難しいからである。 In the process of releasing an object by GC, program execution is generally stopped. This is because the state of the heap area changes due to the GC processing, and it is difficult to execute in parallel with the execution of the program that also changes the state of the heap area.
GCによって発生するプログラムの停止時間は方式によってオブジェクトの生存数、GCを行う領域のサイズ等に比例するが、言語処理システムが扱うオブジェクトの量やヒープ領域のサイズは大規模な環境での運用や半導体技術の向上により増加の傾向にあり、方式によらず停止時間が伸びてきている。 The program stop time generated by GC is proportional to the number of objects alive, the size of the GC area, etc. depending on the method, but the amount of objects handled by the language processing system and the size of the heap area are There is a tendency to increase due to improvement in semiconductor technology, and the stop time is extended regardless of the method.
本発明はこのGCによるプログラムの実行の停止を軽減する為に、マルチスレッド環境にある言語処理システムにおいて、GCの処理中においてもプログラムの実行を続け、GCによる全スレッドの停止を削減することを目的とする。 In the present invention, in order to reduce the suspension of program execution by GC, in a language processing system in a multi-thread environment, program execution is continued even during GC processing, and the suspension of all threads by GC is reduced. Objective.
上記目的を達成する為に、言語処理システムが持つヒープ領域を複製する機能を持たせる。本来複製元で行うGCをこの新しいヒープ領域に対して行うように変更する機能を持たせ、プログラムの動作は複製元のヒープ領域において並列に行うようにする。GC終了後、プログラムの動作を新しいヒープ領域において実行するように切り替える機能を持たせることにより、GCによるプログラムの停止時間を削減する。 In order to achieve the above object, a function for replicating the heap area of the language processing system is provided. A function to change the GC that is originally performed on the replication source to be performed on the new heap area is provided, and the program operation is performed in parallel on the replication heap area. After the GC ends, the program stop time by GC is reduced by providing a function to switch the program operation to be executed in the new heap area.
また、プログラムの実行が新しい領域に切り替わった後に、領域の複製開始から新しい領域においてGCが終了するまで、複製元のヒープ領域において並列に実行していたプログラムが更新した位置を覚えておく機能とテーブルを備えておく。また、新しい領域で行うGCによってオブジェクトが新しいヒープ領域内を移動することがあるので、その移動した量をテーブルに覚えておく。そして、この更新した位置と移動した量を元に、新しいヒープ領域でのGC終了後に複製元の領域で行った更新を新しい領域に対して反映する機能を用意する。この反映処理の最中にもプログラムは実行を続けるので、このプログラムが新しい領域に存在する複製元の領域において更新されたオブジェクトを参照したことを検知する機能と検知した際にその参照を行ったスレッドのみを停止させる機能を持たせる。 In addition, after the program execution has been switched to a new area, from the start of replication of the area until the GC ends in the new area, the function that remembers the updated location of the program that was executed in parallel in the original heap area Have a table. Also, since the object may move in the new heap area due to GC performed in the new area, remember the amount of movement in the table. Then, based on the updated position and the amount moved, a function is provided to reflect the update performed in the copy source area after the end of the GC in the new heap area to the new area. Since the program continues to execute during the reflection process, the program refers to the function when it detects that the updated object is referenced in the copy source area that exists in the new area. Provide a function to stop only the thread.
本発明によれば、GCを行うヒープ領域とプログラムの実行を行うヒープ領域を分けることができる為、GCの実行中にもプログラムの実行を並列に行うことができる。これによってGCの実行中にプログラムを停止する原因が解決する為、プログラムの停止を削減することができる。 According to the present invention, since the heap area for performing GC and the heap area for executing the program can be separated, the program can be executed in parallel even during the execution of the GC. As a result, the cause of stopping the program during the execution of the GC is solved, so that the program stop can be reduced.
以下、計算機システム101上で動作する言語処理システムとしてJavaVM107を使用した場合の実施例について図面に基づいて詳細に説明する。
Hereinafter, an embodiment in which Java VM 107 is used as a language processing system operating on the
図1は、実施形態のJavaVMの構成とその入出力データの図である。計算機システム101は、主記憶(メモリ)105に格納されるJavaVM107の実行を行う中央演算装置130は、JavaVM107がロードされ、各種領域が確保される主記憶105、ファイル等が保存される補助記憶装置102から構成され、主記憶105と中央演算装置130は、バス128によって結合されている。データ領域109はJavaVM107がデータを保持する為に確保された記憶領域であり、その中でもオブジェクトを割り当てる記憶領域がJavaヒープ領域110である。メソッド読み取り部108、メソッド実行部118は、言語処理システムを構成するプログラムである。
FIG. 1 is a diagram of the configuration of the JavaVM and its input / output data according to the embodiment. The
補助記憶装置102に格納されているJavaソースファイル104は、Javaコンパイラ106により、JavaVM107で解釈・実行できる形式であるJavaバイトコードを保持するJavaクラスファイル103に変換され、これがJavaVM107に入力される。JavaVM107に入力されたJavaクラスファイル103は、メソッド読み取り部108によって解析されて、データ領域109にメソッド情報113を作成する。メソッド実行部118は、スレッド機構126からスレッドを割り当てられ、メソッド情報113を読み込むことにより、メソッド情報113に保持されている処理内容を参照ルート114からJavaヒープ領域110にあるオブジェクトを操作することによって、メソッドを実行する。
The Java
本実施形態の対象はメソッドを実行する際にメソッド実行部118がJavaヒープ領域110内に作成したオブジェクトを解放するGCに関するものである。GCはJavaVM107に不要となったオブジェクトを自動で判別して解放するものであるが、これはJavaヒープ管理部120の中のGC実行部121がスレッド機構126からスレッドを割り当てられ、GC実行部121がJavaヒープ領域110内部にあるオブジェクトの必要性を判断してオブジェクトを解放する。このGC実行部121による処理とメソッド実行部118による処理はどちらもスレッド機構126からスレッドを割り当てられているが、どちらもJavaヒープ領域110に対する処理の為、同時に行うことは難しく、GC実行部121が処理を行っている最中はメソッド実行部118に割り当てられた全てのスレッドを停止させる必要がある。このGC処理を行っている最中に発生する全てのスレッド停止を低減する為に本発明を考案した。
The object of this embodiment relates to a GC that releases an object created in the Java
コンピュータを前記各処理部として機能させる為のプログラムは、CD−ROM等の記録媒体に記録され磁気ディスク等に格納された後、メモリにロードされて実行されるものとする。なお前記プログラムを記録する記録媒体はCD−ROM以外の他の記録媒体でも良い。また前記プログラムを当該記録媒体から情報処理装置にインストールして使用しても良いし、ネットワークを通じて当該記録媒体にアクセスして前記プログラムを使用するものとしても良い。 A program for causing a computer to function as each processing unit is recorded on a recording medium such as a CD-ROM and stored in a magnetic disk or the like, and then loaded into a memory and executed. The recording medium for recording the program may be a recording medium other than the CD-ROM. The program may be used by installing it from the recording medium into the information processing apparatus, or the program may be used by accessing the recording medium through a network.
図2は、本実施形態のJavaVM107においてのフローチャートである。最初にJavaヒープコピー部122のコピー部123がJavaヒープ領域110の複製を行ってJavaヒープ領域(新)112を生成し、Javaヒープコピー部122はJavaヒープ領域110をJavaヒープ領域(旧)111とする。この処理がJavaヒープ領域コピー処理201である。
FIG. 2 is a flowchart in the JavaVM 107 of this embodiment. First, the
その処理が終了した後、GC実行部121にスレッド機構126から割り当てられたスレッドに対してスレッド制御部125は通常Javaヒープ領域(旧)111において行われるGC処理をJavaヒープ領域(新)112で行うように、GC処理の行われるJavaヒープ領域を示す記憶装置内の情報を変更する。また、GC処理においてオブジェクトの位置が移動した場合にはGC実行部121はその移動した量を移動オフセットテーブル115に記録する。この処理はJavaヒープ領域(新)GC処理202である。
After the processing is completed, the
Javaヒープ領域コピー処理201及びJavaヒープ領域(新)GC処理202の動作中はメソッド実行部118によりプログラムの実行がJavaヒープ領域(旧)111において並列して行われている。この処理の間、更新テーブル管理部117はメソッド実行部118がJavaヒープ領域(旧)111においてデータを更新したことを更新管理テーブル116に記憶しておく。この処理は図10の更新テーブル管理処理であり、この更新管理テーブル116はこの後の処理に使用される。
During the operations of the Java heap
次に参照管理部124はJavaヒープ領域(旧)111を指している参照ルート114を示す記憶装置内の情報をJavaヒープ領域(新)112を指すように変更して参照ルートを切り替える。この処理より前において参照ルート114はJavaヒープ領域(旧)111を指していた為、メソッド実行部118はJavaヒープ領域(旧)111に対して処理を行っていた。この参照ルート114を、Javaヒープ領域(新)112を指すように変更することによってメソッド実行部118によって動作するプログラムはJavaヒープ領域(新)112で動作するようになる。この処理は領域切り替え処理203である。
Next, the
最後に参照管理部124はメソッド実行部118がJavaヒープ領域コピー処理201及びJavaヒープ領域(新)GC処理202の最中にJavaヒープ領域(旧)111において行ったデータの更新をJavaヒープ領域(新)112に反映する。Javaヒープ領域(旧)111において更新を行ったデータの位置は更新管理テーブル116で記録されているので、その位置と移動オフセットテーブル115から、Javaヒープ領域(旧)111にあるデータのJavaヒープ領域(新)112での位置が計算できる。この計算結果によりJavaヒープ領域(旧)111にあるデータをJavaヒープ領域(新)112に上書きする。その後、Javaヒープコピー部122はJavaヒープ領域(旧)111を解放し、Javaヒープ領域(新)112をJavaヒープ領域110とする。この処理はJavaヒープ領域(旧)更新内容反映処理204である。
Finally, the
領域切り替え処理203及びJavaヒープ領域(旧)更新内容反映処理204の動作中はメソッド実行部118によりプログラムの実行がJavaヒープ領域(新)112において並列して行われている。領域切り替え処理203が終了する前は参照ルート114がJavaヒープ領域(旧)111を参照しているのでメソッド実行部118はJavaヒープ領域(旧)111の上で動作を行おうとする。そこで例外処理部119がJavaヒープ領域(旧)111の上でメソッド実行部118が動作しようとしたことを検知して参照ルート114がJavaヒープ領域(新)112を指すように変更する。Javaヒープ領域(旧)更新内容反映処理204が終了する前はメソッド実行部118がJavaヒープ領域(旧)111の更新済みのデータに対応するJavaヒープ領域(新)112のデータに対して参照を行ってしまうと、既にJavaヒープ領域(旧)111で行った更新内容が正しく扱われなくなる。そこで例外処理部119は、Javaヒープ領域(旧)111の更新済みのデータに対応するJavaヒープ領域(新)112のデータに対してメソッド実行部118が参照しようとしたことを検知して、その参照を行ったメソッド実行部118にスレッド機構126から割り当てられているスレッドのみを停止させる。この停止することとなったスレッドはJavaヒープ領域(旧)更新内容反映処理204の最後において再開される。この処理は図11の参照例外処理である。
During operation of the
以上の処理によって、本実施形態において、実施前ではGC処理が行われていなかったJavaヒープ領域110がメソッド実行部118によってプログラムを実行しながらもGC処理を行うことができ、実施後にはJavaヒープ領域110がプログラムの並列動作にもかかわらず正常にGC処理を行われている状態を実現することができる。
With the above processing, in this embodiment, the
図3は、実施形態の各々の処理がどのタイミングで行われるかを示す図である。上記で述べたように図10の更新テーブル管理処理はJavaヒープ領域コピー処理201及びJavaヒープ領域(新)GC処理202と並列に実行されており、また図11の参照例外処理は領域切り替え処理203及びJavaヒープ領域(旧)更新内容反映処理204と並列に実行される。この為、図10の更新テーブル管理処理と図11の参照例外処理は同時に実行されることがない。
FIG. 3 is a diagram illustrating at which timing each process of the embodiment is performed. As described above, the update table management process of FIG. 10 is executed in parallel with the Java heap
図4は、更新管理テーブル116を示す図である。Javaヒープ領域コピー処理201及びJavaヒープ領域(新)GC処理202の動作中に、メソッド実行部118がプログラムを実行することでJavaヒープ領域(旧)111に存在するオブジェクトを更新した際に更新管理テーブル116の値を変更する。このテーブルの持つ値はオブジェクトの更新が行われたかどうかのみを記録するだけでよいので1ビットで表現できる。また、Javaヒープ領域(旧)111に存在する全てのオブジェクトに対して管理することが求められるが、それを行うとテーブルのサイズが大きくなってしまう。その為、Javaヒープ領域(旧)111を論理的に分割し、それぞれについて管理する。従って、更新されたオブジェクト401がその分割された領域の中に1つ以上あった時のみテーブルの値を1に変更すればよく、更新されていないオブジェクト402しかない場合は、テーブルの値を0のままにしておけばよい。
FIG. 4 is a diagram showing the update management table 116. Update management when the
図5は、移動オフセットテーブル115を示す図である。移動オフセットテーブル115はJavaヒープ領域(新)GC処理202の最中にGC実行部121が行うGC処理において、GC処理で消滅するオブジェクト501以外のオブジェクトがGC処理によって何アドレス分移動したかを記録するテーブルである。GCによってオブジェクトがどのように移動するかは不定であり、Javaヒープ領域(旧)111にあったオブジェクトがJavaヒープ領域(新)112のどの位置に存在するかを計算する為に必要である。全てのオブジェクトに対して記録する必要はなく、GC処理で消滅するオブジェクト501以外のオブジェクトについてのみを記録すればよく、また隣り合っているオブジェクトのような、GC処理による移動量が同じオブジェクトについてはまとめて1つのデータとして記録すればよい。
FIG. 5 is a diagram showing the movement offset table 115. The move offset table 115 records how many addresses other than the
図6は、Javaヒープ領域コピー処理201を表したフローチャートである。Javaヒープコピー部122は現在メソッド実行部118によってプログラムが動いているJavaヒープ領域110をJavaヒープ領域(旧)111とする(ステップ601)。この後にコピー部123によりJavaヒープ領域(旧)111のデータをコピーすることによってJavaヒープ領域(新)112を生成する。
FIG. 6 is a flowchart showing the Java heap
Javaヒープ領域(旧)111にあるデータはオブジェクトであり、実際にはJavaヒープ領域(旧)111にある全てのオブジェクトをコピーすることになる。その為、Javaヒープ領域(旧)111の先頭から順にコピーを行っていくので、まずはコピー部123が全てのデータをコピーしたかを判定する(ステップ602)。全てのデータのコピーが終わっていない場合は、データをコピーする必要がある。
The data in the Java heap area (old) 111 is an object, and all objects in the Java heap area (old) 111 are actually copied. Therefore, since copying is performed in order from the top of the Java heap area (old) 111, it is first determined whether the
ここでコピーするデータについてだが、参照データについてはそのままデータをコピーしてはいけない。図7に参照データ及び参照データをそのままコピーしてはいけない理由を示す。ここでオブジェクトA701が持つデータとしてオブジェクトB702を導き出す為のメモリのアドレス703と数値704があるとする。このオブジェクトA701からオブジェクトB702のメモリのアドレス703へのポインタ705が参照データであるが、この値をそのままコピーしてJavaヒープ領域(新)にオブジェクトA701を生成してしまうと、メモリのアドレス703の数値はそのままである為、Javaヒープ領域(旧)111にあるオブジェクトB702へのポインタ707となってしまう。この為、Javaヒープ領域(旧)111とJavaヒープ領域(新)112のアドレスの差分706をメモリのアドレス703に足しこむことによりJavaヒープ領域(新)112にあるオブジェクトB702へのポインタ708にする。
As for the data to be copied here, the reference data should not be copied as it is. FIG. 7 shows the reason why the reference data and the reference data should not be copied as they are. Here, it is assumed that there is a
以上の理由により、コピーする値が参照であるか、参照でないかを判定する必要がある(ステップ603)。参照でない場合はそのままの値をJavaヒープ領域(新)112にコピーする(ステップ604)。参照の場合はコピーする値をJavaヒープ領域(旧)111とJavaヒープ領域(新)112のアドレスの差分だけ増加させてコピーを行う(ステップ605)。これによって参照の値もJavaヒープ領域(新)112を指すようになる。全てのJavaヒープ領域(旧)のデータに対して処理を行ったらJavaヒープ領域コピー処理201を終了する(ステップ602)。
For these reasons, it is necessary to determine whether the value to be copied is a reference or not (step 603). If it is not a reference, the value as it is is copied to the Java heap area (new) 112 (step 604). In the case of reference, copying is performed by increasing the value to be copied by the difference between the addresses of the Java heap area (old) 111 and the Java heap area (new) 112 (step 605). As a result, the reference value also points to the Java heap area (new) 112. When processing has been performed on all the data in the Java heap area (old), the Java heap
図8は、Javaヒープ領域(新)GC処理202を表したフローチャートである。本来、GC実行部121はスレッド機構126からスレッドを割り当てられJavaヒープ領域110においてGC処理を行う。実際にはJavaヒープ領域110はJavaヒープ領域(旧)111である。ここでスレッド制御部125は、スレッド機構126がGC実行部121に割り当てたスレッドに対してGC処理をJavaヒープ領域(新)112でGC処理を行うように切り替える(ステップ801)。これによってGC実行部121はGC処理をJavaヒープ領域(新)112において行うようになる(ステップ802)。図5で述べたように、GC処理によって移動したオブジェクトは移動オフセットテーブル115に記録しなければならない(ステップ803)。
FIG. 8 is a flowchart showing the Java heap area (new)
図9は、領域切り替え処理203を表したフローチャートである。ここでは、参照ルート114がJavaヒープ領域(旧)111を指しているのをJavaヒープ領域(新)112を指すようにする。ここで問題となるのはこの処理と並列にメソッド実行部118によりプログラムが実行されていることである。その為、メソッド実行部118がJavaヒープ領域(旧)111で行った更新をJavaヒープ領域(新)112に反映する前にそのオブジェクトをメソッド実行部118が参照した場合に結果が不正となってしまう。メソッド実行部118が不正な実行を行おうとしたことを検知する方法を図10において説明する。更新管理テーブル116によりJavaヒープ領域(旧)111において更新されたオブジェクト401の位置がわかる。まずはこの更新されたオブジェクト401がJavaヒープ領域(新)112においてどの位置に存在するかを計算する。それは更新されたオブジェクト401のJavaヒープ領域(旧)111の位置、Javaヒープ領域(旧)111とJavaヒープ領域(新)112のアドレスの差分706、更新されたオブジェクト401に対応する移動オフセットテーブル115の値1001の和が更新されたオブジェクト401のJavaヒープ領域(新)112における位置である。このオブジェクトに対してメソッド実行部118がデータを参照した際に例外が発生するようにこの領域をガード領域1002とする。以上のことを実現する為に次の処理を行う。
FIG. 9 is a flowchart showing the
最初に全ての更新管理テーブル116に対して処理を行ったかを判定する(ステップ901)。完了していない場合は、更新管理テーブル116にある更新されたオブジェクト401に対して以下の処理を行っていく。まずは更新されたオブジェクト401が移動オフセットテーブル115に登録されているかを判定する(ステップ902)。これを行う理由としてはJavaヒープ領域コピー処理201より後でJavaヒープ領域(旧)111生成されたオブジェクト1101を判定する必要があるからである。
First, it is determined whether or not all the update management tables 116 have been processed (step 901). If not completed, the following processing is performed on the updated object 401 in the update management table 116. First, it is determined whether or not the updated object 401 is registered in the movement offset table 115 (step 902). The reason for doing this is that it is necessary to determine the
図11にJavaヒープ領域コピー処理201より後でJavaヒープ領域(旧)111に生成されたオブジェクト1101が存在する状態を示す。移動オフセットテーブル115に登録されていないオブジェクトはGC処理で消滅するオブジェクト501であるかJavaヒープ領域コピー処理201より後でJavaヒープ領域(旧)111に生成されたオブジェクト1101である。また、GC処理で消滅するオブジェクト501はどこからも参照されていないオブジェクトであり更新することができない。よって、更新管理テーブル116に登録されているオブジェクトかつ移動オフセットテーブル115に登録されていないオブジェクトはJavaヒープ領域コピー処理201より後で生成されたオブジェクトと判定することができる。
FIG. 11 shows a state where an
このJavaヒープ領域コピー処理201より後で生成されたオブジェクトがJavaヒープ領域(新)112に存在しないままでは後のJavaヒープ領域(旧)更新内容反映処理204において不都合が生じる為、ここでJavaヒープ領域コピー処理201より後でJavaヒープ領域(旧)111に生成されたオブジェクト1101の場合は、情報を持たないダミーオブジェクト1102をJavaヒープ領域(新)112に生成する(ステップ903)。そして、このダミーオブジェクト1102を移動オフセットテーブル115に登録する(ステップ904)。ダミーオブジェクト1102が持つデータは特に定める必要はなく不定な値1103でよく、ダミーオブジェクト1102はJavaヒープ領域コピー処理201より後でJavaヒープ領域(旧)111に生成されたオブジェクト1101と同じサイズを持っていればよい。
If an object generated after the Java heap area copy processing 201 does not exist in the Java heap area (new) 112, there will be inconvenience in the subsequent Java heap area (old) update
ステップ904が終了後またはステップ902によって更新されたオブジェクト401が移動オフセットテーブル115に登録されていると判定された場合は、ダミーオブジェクト1102または更新されたオブジェクト401に対応するJavaヒープ領域(新)112にあるオブジェクトをガード領域とする(ステップ905)。
After step 904 is completed or when it is determined that the object 401 updated in
上記の処理が終了した後、Javaヒープ領域(旧)111を指している参照ルート114をJavaヒープ領域(新)112を指すように変更する。それにはまずJavaヒープ領域(旧)111全体をガード領域とする(ステップ906)。これはメソッド実行部118によって領域切り替え処理203と並列に実行されているプログラムよってJavaヒープ領域(新)112に切り替える前にJavaヒープ領域(旧)111を参照された場合を検知する為である。
After the above processing is completed, the
また、この処理の後に全ての参照ルート114をガード領域とする(ステップ907)。これは参照ルート114を切り替えている途中で、一度Javaヒープ領域(新)112に切り替えた参照ルート114をJavaヒープ領域(旧)111を指すように他のJavaヒープ領域(旧)111を指している参照ルート114で上書きされないためである。図12にステップ906及びステップ907を行った後の参照ルート114、Javaヒープ領域(旧)111及びJavaヒープ領域(新)112の状態を示す。
After this processing, all
ステップ906及びステップ907が終わった後、全ての参照ルート114に対して切り替え処理を行う。全ての参照ルート114がJavaヒープ領域(新)112を指している場合は処理が終了しており、指していない場合は処理がまだ終了していない(ステップ908)。処理が終了していない場合はそれぞれの参照ルート114に対して参照ルート114のガード領域を解除して参照ルート114をJavaヒープ領域(旧)111からJavaヒープ領域(新)112を指すように変更する(ステップ909)。このJavaヒープ領域(旧)111を指している参照をJavaヒープ領域(新)112を指すように変更する為には、Javaヒープ領域(新)112での位置を計算しなければならない。この計算はJavaヒープ領域(新)112の更新されたオブジェクト401をガード領域とした時の計算と同じ計算方法で行うことができる。全ての参照ルート114をJavaヒープ領域(新)112を指すように変更した後、Javaヒープ領域(旧)111全体にかけたガード領域を解除する(ステップ910)。これら一連の処理で領域切り替え処理203を行う。
After
図13は、Javaヒープ領域(旧)更新内容反映処理204を表したフローチャートである。Javaヒープ領域(旧)更新内容反映処理204は更新管理テーブル116に登録されている全ての更新内容を反映する必要があるので、まずは全ての更新内容が反映されているかを判定する(ステップ1301)。全ての更新内容が反映されていない場合は、未反映のJavaヒープ領域(新)112にあるオブジェクトにかかっているガード領域を解除する(ステップ1302)。
FIG. 13 is a flowchart showing the Java heap area (old) update
そして、そのJavaヒープ領域(新)112にあるオブジェクトに対してJavaヒープ領域(旧)にあるデータと同じ内容にする必要があるが、Javaヒープ領域コピー処理201の時と同じように、参照の値だけはそのままの値を上書きするとJavaヒープ領域(旧)111を指してしまう。この為、更新されたオブジェクト401のデータの値が参照かどうかを判定する(ステップ1303)。参照でない場合はそのままの値をJavaヒープ領域(新)112に上書きする(ステップ1304)。参照の場合は領域切り替え処理203のステップ909と同じ方法で参照をJavaヒープ領域(旧)111からJavaヒープ領域(新)112を指すように変更する(ステップ1305)。
Then, the object in the Java heap area (new) 112 needs to have the same contents as the data in the Java heap area (old), but as with the Java heap
全ての更新反映処理が終了した後、Javaヒープコピー部120はJavaヒープ領域(新)112をJavaヒープ領域110として扱うように変更する(ステップ1306)。その後、不要となったJavaヒープ領域(旧)111を解放する(ステップ1307)。最後に、後述する例外処理部119によって停止されていたスレッドを全て再開させることによってメソッド実行部118によるプログラムの実行を通常の状態に戻す(ステップ1308)。
After all the update reflection processes are completed, the Java heap copy unit 120 changes the Java heap area (new) 112 to be handled as the Java heap area 110 (step 1306). Thereafter, the Java heap area (old) 111 that is no longer needed is released (step 1307). Finally, the execution of the program by the
以上のJavaヒープ領域コピー処理201、Javaヒープ領域(新)GC処理202、領域切り替え処理203、Javaヒープ領域(旧)更新内容反映処理204によって、メソッド実行部118にプログラムの実行を処理させると同時に並列にGC処理を行うことができる。しかし、まだ更新管理テーブル116を更新する更新テーブル管理部117の処理とメソッド実行部118がプログラムを実行する際に参照したら不正となる領域を参照した場合に行う処理について述べていない。それらについては以下で述べる。
At the same time as causing the
図14は、更新テーブル管理処理を表したフローチャートである。図2で述べたようにメソッド実行部118がJavaヒープ領域(旧)111で行った更新はJavaヒープ領域コピー処理201及びJavaヒープ領域(新)GC処理202の最中に記録するだけでよい。この為、更新テーブル管理部117は現在がJavaヒープ領域コピー処理201及びJavaヒープ領域(新)GC処理202の最中であるかを判定する(ステップ1401)。Javaヒープ領域コピー処理201及びJavaヒープ領域(新)GC処理202の最中でない場合は更新テーブル管理部117の処理は終了する。Javaヒープ領域コピー処理201及びJavaヒープ領域(新)GC処理202の最中である場合は、メソッド実行部118がJavaヒープ領域(旧)111に対して更新処理を行ったかを判定する(ステップ1402)。Javaヒープ領域(旧)111に対して更新処理を行った場合はJavaヒープ領域(旧)111にあるオブジェクトの位置に対応した更新管理テーブル116のビットを操作して更新したことを記録する(ステップ1403)。
FIG. 14 is a flowchart showing the update table management process. As described in FIG. 2, the update performed by the
図15は、参照例外処理を表したフローチャートである。例外処理部119はメソッド実行部118がプログラムの実行中に発生させた例外を補足して以下の処理を実行する。例外が発生するのは領域切り替え処理203において参照ルート114、Javaヒープ領域(旧)111、Javaヒープ領域(新)112に対してかけたガード領域に対してメソッド実行部118が参照を行った場合である。
FIG. 15 is a flowchart showing the reference exception process. The
メソッド実行部118によるプログラムの実行中に例外が発生した際にはその例外がどの領域を参照したことによって発生したかを判定する(ステップ1501)。例外が発生した領域が参照ルート114であった場合は、その参照ルート114は領域切り替え処理203による参照ルート114のJavaヒープ領域(新)112への切り替えが終わっていないので、まずは参照ルート114のガード領域を解除し(ステップ1502)、参照ルート114の指す先をJavaヒープ領域(旧)111からJavaヒープ領域(新)112に切り替える(ステップ1503)。
When an exception occurs during the execution of the program by the
また例外が補足された領域がJavaヒープ領域(旧)111である場合は、参照ルート114がJavaヒープ領域(旧)111を指しているままなのでJavaヒープ領域(新)112を指すように変更する(ステップ1503)。また、例外が発生した領域がJavaヒープ領域(新)112である場合は、Javaヒープ領域(旧)更新内容反映処理204によるJavaヒープ領域(旧)111で更新した内容が反映される前なので、例外を発生させたメソッド実行部118にスレッド機構126から割り当てされたスレッドのみをスレッド制御部125が停止させる(ステップ1504)。この停止したスレッドはJavaヒープ領域(旧)更新内容反映処理204のステップ1308で再開される。
If the area supplemented with the exception is the Java heap area (old) 111, the
以上説明した通り、本実施形態により、プログラムの実行と並列にGC処理を行うことができ、そのGC処理を起こっている最中にプログラムの実行によって更新されたJavaヒープ領域のデータの内容をGC処理が終了した先へ反映することが可能となる。 As described above, according to this embodiment, the GC process can be performed in parallel with the execution of the program, and the contents of the data in the Java heap area updated by the execution of the program during the GC process are displayed in the GC. It is possible to reflect the result at the end of processing.
101…計算機システム、102…補助記憶装置、103…Javaクラスファイル、104…Javaソースファイル、105…主記憶、106…Javaコンパイラ、107…JavaVM、108…メソッド読み取り部、109…データ領域、110…Javaヒープ領域、111…Javaヒープ領域(旧)、112…Javaヒープ領域(新)、113…メソッド情報、114…参照ルート、115…移動オフセットテーブル、116…更新管理テーブル、117…更新テーブル管理部、118…メソッド実行部、119…例外処理部、120…Javaヒープ管理部、121…GC実行部、122…Javaヒープコピー部、123…コピー部、124…参照管理部、125…スレッド制御部、126…スレッド機構、127…オペレーティングシステム、128…バス、129…出力装置、130…中央演算装置、131…入力装置
DESCRIPTION OF
Claims (5)
前記計算機システムがプログラムによって参照または更新可能なオブジェクトを格納した記憶装置内の第1のヒープ領域の内容を前記記憶装置内の第2のヒープ領域に格納し、前記計算機システムがガーベージコレクションの行われるヒープ領域を示す記憶装置内の情報を前記第1のヒープ領域を示す内容から前記第2のヒープ領域を示す内容へ変更し、前記計算機システムが前記第2のヒープ領域でガーベージコレクションを実行すると共に前記第2のヒープ領域でのガーベージコレクションの実行中も継続して前記プログラムを実行し、前記第2のヒープ領域でのガーベージコレクションの実行後、前記計算機システムが前記プログラムによってオブジェクトを参照する際の参照ルートを示す記憶装置内の情報を前記第1のヒープ領域から前記第2のヒープ領域を指す内容に変更することを特徴とするガーベージコレクション方法。 In a garbage collection method in a computer system that performs garbage collection of an object stored in a storage device,
The contents of the first heap area in the storage device in which the computer system stores objects that can be referenced or updated by a program are stored in the second heap area in the storage device, and the computer system is garbage collected. The information in the storage device indicating the heap area is changed from the contents indicating the first heap area to the contents indicating the second heap area, and the computer system executes garbage collection in the second heap area. The program is continuously executed during execution of garbage collection in the second heap area. After execution of garbage collection in the second heap area, the computer system refers to an object by the program. Whether the information in the storage device indicating the reference route is the first heap area Garbage collection method characterized by changing the contents to refer to the second heap.
プログラムによって参照または更新可能なオブジェクトを格納した記憶装置内の第1のヒープ領域の内容を記憶装置内の第2のヒープ領域に格納するコピー部と、ガーベージコレクションの行われるヒープ領域を示す記憶装置内の情報を、前記第1のヒープ領域を示す内容から前記第2のヒープ領域を示す内容へ変更するスレッド制御部と、前記第2のヒープ領域でガーベージコレクションを実行するガーベージコレクション実行部と、前記第2のヒープ領域でのガーベージコレクションの実行中も継続して前記プログラムを実行するスレッド実行部と、前記第2のヒープ領域でのガーベージコレクションの実行後、前記プログラムによってオブジェクトを参照する際の参照ルートを示す記憶装置内の情報を、前記第1のヒープ領域から前記第2のヒープ領域を指す内容に変更する参照管理部とを備えることを特徴とする計算機システム。 In a computer system that performs garbage collection of objects stored in a storage device,
A copy unit that stores the contents of a first heap area in a storage device that stores objects that can be referenced or updated by a program in a second heap area in the storage device, and a storage device that indicates a heap area in which garbage collection is performed A thread control unit for changing the information in the content indicating the first heap area from the content indicating the second heap area, and a garbage collection executing part for executing garbage collection in the second heap area, A thread execution unit that continuously executes the program even during execution of garbage collection in the second heap area; and after executing garbage collection in the second heap area, when the object is referred to by the program The information in the storage device indicating the reference route is obtained from the first heap area. Computer system, characterized in that it comprises a reference management unit for changing the contents to refer to the second heap.
前記計算機システムがプログラムによって参照または更新可能なオブジェクトを格納した記憶装置内の第1のヒープ領域の内容を前記記憶装置内の第2のヒープ領域に格納し、前記計算機システムがガーベージコレクションの行われるヒープ領域を示す記憶装置内の情報を前記第1のヒープ領域を示す内容から前記第2のヒープ領域を示す内容へ変更し、前記計算機システムが前記第2のヒープ領域でガーベージコレクションを実行すると共に前記第2のヒープ領域でのガーベージコレクションの実行中も継続して前記プログラムを実行し、前記第2のヒープ領域でのガーベージコレクションの実行後、前記計算機システムが前記プログラムによってオブジェクトを参照する際の参照ルートを示す記憶装置内の情報を前記第1のヒープ領域から前記第2のヒープ領域を指す内容に変更するガーベージコレクション方法をコンピュータに実行させることを特徴とするプログラム。 In a program for causing a computer to execute a garbage collection method in a computer system that performs garbage collection of objects stored in a storage device,
The contents of the first heap area in the storage device in which the computer system stores objects that can be referenced or updated by a program are stored in the second heap area in the storage device, and the computer system is garbage collected. The information in the storage device indicating the heap area is changed from the contents indicating the first heap area to the contents indicating the second heap area, and the computer system executes garbage collection in the second heap area. The program is continuously executed during execution of garbage collection in the second heap area. After execution of garbage collection in the second heap area, the computer system refers to an object by the program. Whether the information in the storage device indicating the reference route is the first heap area A program characterized by executing the garbage collection process to change the contents to refer to the second heap area computer.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2008040926A JP2009199391A (en) | 2008-02-22 | 2008-02-22 | Garbage collection method, and its execution device, and processing program |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2008040926A JP2009199391A (en) | 2008-02-22 | 2008-02-22 | Garbage collection method, and its execution device, and processing program |
Publications (1)
Publication Number | Publication Date |
---|---|
JP2009199391A true JP2009199391A (en) | 2009-09-03 |
Family
ID=41142811
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2008040926A Pending JP2009199391A (en) | 2008-02-22 | 2008-02-22 | Garbage collection method, and its execution device, and processing program |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP2009199391A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2010137600A1 (en) * | 2009-05-25 | 2010-12-02 | 株式会社日立製作所 | Memory management method, computer system, and storage medium in which program is stored |
-
2008
- 2008-02-22 JP JP2008040926A patent/JP2009199391A/en active Pending
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2010137600A1 (en) * | 2009-05-25 | 2010-12-02 | 株式会社日立製作所 | Memory management method, computer system, and storage medium in which program is stored |
JP2010272059A (en) * | 2009-05-25 | 2010-12-02 | Hitachi Ltd | Memory management method computer system and program |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Moraru et al. | Consistent, durable, and safe memory management for byte-addressable non volatile main memory | |
US8438193B2 (en) | Copy collector with efficient abort-on-copy transition to mark collector | |
JP5618796B2 (en) | Computer, computer control method and program | |
JP6044181B2 (en) | Information processing method, program and apparatus for garbage collection | |
JP2010238228A (en) | Method and device for dynamically analyzing program | |
JP4676289B2 (en) | Debug system and method | |
JP5391422B2 (en) | Memory management method, computer system, and program | |
US8296742B2 (en) | Automatic native generation | |
KR101996641B1 (en) | Apparatus and method for memory overlay | |
JP2009199391A (en) | Garbage collection method, and its execution device, and processing program | |
JP5987501B2 (en) | Branch address management program, method, and apparatus | |
US20120054723A1 (en) | Dynamic instrumentation method and apparatus thereof | |
JP2018097817A (en) | Information processor, information processing method and program | |
WO2011104889A1 (en) | Computer system, memory management method and memory management program | |
KR102150597B1 (en) | Method for operating hybrid transactional memory system with optimal retry policy, and hybrid transactional memory system | |
JP5316148B2 (en) | Information processing apparatus and data restoration method | |
KR100928865B1 (en) | Stack expansion and protection methods in computer systems and devices therefor | |
JP2012084069A (en) | Computer system and failure information collection method | |
JP2009230395A (en) | Journal log recording control method | |
JP2005284647A (en) | Parallel processor, instruction retry method, and program | |
JP2008197980A (en) | Failure analysis file weight reduction device for distributed parallel program, its method and its program | |
WO2016002225A1 (en) | Information processing device, data element recovery method, and computer-readable recording medium having program stored therein | |
JP2006323763A (en) | Language processing operation method and system | |
JP2007094922A (en) | Automatic program generation, method, and program | |
JP2006277429A (en) | Method for dynamic alteration of instruction using bypass route |