JP2003050740A - Device and method of garbage collection - Google Patents

Device and method of garbage collection

Info

Publication number
JP2003050740A
JP2003050740A JP2002154671A JP2002154671A JP2003050740A JP 2003050740 A JP2003050740 A JP 2003050740A JP 2002154671 A JP2002154671 A JP 2002154671A JP 2002154671 A JP2002154671 A JP 2002154671A JP 2003050740 A JP2003050740 A JP 2003050740A
Authority
JP
Japan
Prior art keywords
cell
memory cell
counter
referenced
garbage collection
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.)
Granted
Application number
JP2002154671A
Other languages
Japanese (ja)
Other versions
JP4041347B2 (en
Inventor
Takehiro Yoshida
健宏 吉田
Takuji Kawamoto
▲たく▼二 川本
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Panasonic Holdings Corp
Original Assignee
Matsushita Electric Industrial Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Matsushita Electric Industrial Co Ltd filed Critical Matsushita Electric Industrial Co Ltd
Priority to JP2002154671A priority Critical patent/JP4041347B2/en
Publication of JP2003050740A publication Critical patent/JP2003050740A/en
Application granted granted Critical
Publication of JP4041347B2 publication Critical patent/JP4041347B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Abstract

PROBLEM TO BE SOLVED: To provide a device for performing effective garbage collection by suppressing memory use quantity, when the number of referred memory cells instantaneously takes a large peak value by an operation of an application program(AP). SOLUTION: Counters as small bit strings so that the peak value of the number of referred memory cells cannot be expressed are provided in the respective memory cells, a garbage collection device 100 increases/decreases a counter within a range equal to or less than the maximum value to be expressed by the bit strings by a counter changing part 110, in the case of changes of pointers to the memory cell by the AP; and when the counter show zero, releases the memory cell by a cell releasing part 130, in addition, checks the number of the respective referred memory cells by tracing a pointer chain from a route pointer by a recounting part 140 in the case of shortage of memory, etc., releases the memory cell the result of which is zero and sets the number of checking results in counters of memory cells except zero by a counter resetting part 142.

Description

【発明の詳細な説明】Detailed Description of the Invention

【0001】[0001]

【発明の属する技術分野】本発明は、アプリケーション
プログラムが使用したメモリについてのガベージコレク
ションに関し、特にリファレンスカウント方式を用いる
ガベージコレクションの技術に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a garbage collection of a memory used by an application program, and more particularly to a garbage collection technique using a reference counting method.

【0002】[0002]

【従来の技術】従来のプログラミング言語には、アプリ
ケーションプログラムの作成者にメモリ領域の確保や解
放を意識させず、アプリケーションプログラムが使用し
た後に不要となったメモリ領域の解放を実行環境側に任
せる方法を採るものがある。例えばJava言語であ
る。なお、Javaは米国Sun Microsyst
ems社の商標である。
2. Description of the Related Art A conventional programming language is a method in which the creator of an application program is not aware of securing or freeing a memory area and leaves the memory area that is no longer needed after the application program uses it to the execution environment side. There are things that take. For example, the Java language. Java is Sun Microsystem in the United States.
is a trademark of ems.

【0003】このような言語を用いて記述されたアプリ
ケーションプログラムは、不要となったメモリ領域を自
動的に解放するガベージコレクション機構を備える実行
環境上で動かされる。ガベージコレクション機構は、ア
プリケーションプログラムの実行に際して動的に確保さ
れたメモリセル(以下、単に「セル」という。)がどこ
からも参照されていない状態になっていることを検出し
てそのセルを解放し再利用可能状態にする。この一度確
保されたセルを解放して再利用可能状態にすることを、
セルを回収するともいう。
An application program written using such a language is run on an execution environment having a garbage collection mechanism for automatically releasing an unnecessary memory area. The garbage collection mechanism detects that a dynamically secured memory cell (hereinafter simply referred to as “cell”) is not referenced from anywhere when the application program is executed, and releases the cell. Make it reusable. To release the once secured cell and make it reusable,
Also referred to as collecting cells.

【0004】ここで、セルとは、アプリケーションプロ
グラムが実行時に動的に用いることのできるヒープ領域
を細分化した単位をいう。各セルは、例えばオブジェク
ト指向プログラミング言語におけるいわゆるオブジェク
トインスタンスに対応するひとまとまりの可変長領域で
あり、各セルの内容は、データとデータ型との組の集合
である部分と、セルが有効であるか否かを示す有効セル
フラグ等を含む管理用の情報である部分とからなる。
Here, a cell is a unit obtained by subdividing a heap area that can be dynamically used by an application program at the time of execution. Each cell is, for example, a group of variable-length areas corresponding to so-called object instances in an object-oriented programming language, and the content of each cell is a portion that is a set of a set of data and a data type, and the cell is effective. And a portion which is information for management including a valid cell flag indicating whether or not.

【0005】なお、データ型は、対応するデータが例え
ば整数、論理値、ポインタ等のいずれであるかの別を示
すものであり、以下、ポインタ型のデータを単に「ポイ
ンタ」ともいう。また、有効セルフラグはセルが確保さ
れた時から有効を示す値をとりセルが解放された時点で
ガベージコレクション機構により無効を示す値にされる
フラグである。
The data type indicates whether the corresponding data is, for example, an integer, a logical value, a pointer, or the like. Hereinafter, the pointer type data is also simply referred to as a "pointer". Further, the valid cell flag is a flag which takes a value indicating valid from the time when the cell is secured and is set to a value indicating invalid by the garbage collection mechanism when the cell is released.

【0006】セルの参照は、そのセルへのポインタを保
持することによりなされ、例えば、セルAからセルBを
参照する場合には、セルAはセルBのポインタを内容と
して含む。ある時点においてアプリケーションプログラ
ムにより参照されている全てのセルは、1又は複数のル
ートポインタなるポインタから、直接又は1以上のセル
内のポインタを媒介にして、辿ることができる。ここ
で、ルートポインタは、例えばアプリケーションプログ
ラム全体やその一部を単位としてその単位毎に定めら
れ、アプリケーションプログラムの実行環境によって、
その単位毎に最初に確保されたセルのメモリアドレスが
ルートポインタに格納される。
A reference to a cell is made by holding a pointer to that cell. For example, when referring to cell B from cell A, cell A contains the pointer of cell B as its content. All cells referenced by the application program at a given time can be traced from one or more root pointers, either directly or via pointers in one or more cells. Here, the root pointer is defined for each unit, for example, with the whole application program or a part thereof as a unit, and depending on the execution environment of the application program,
The memory address of the cell initially secured for each unit is stored in the root pointer.

【0007】従って、ガベージコレクション機構は、あ
る時点においてルートポインタから辿れなくなっている
セルを不要なものとして回収対象にする。以下、従来の
ガベージコレクションの方式について説明する。<0-
1.マークアンドスイープ方式>マークアンドスイープ
方式は、公開特許公報(特開平11−232162号)
に開示されており、ルートポインタから辿れる全てのセ
ルにマークを付けていく処理を行った後に、全てのセル
を走査して、マークの付いていないセルを回収する方式
である。
Therefore, the garbage collection mechanism treats a cell that cannot be traced from the root pointer at a certain time point as an unnecessary cell to be collected. Hereinafter, a conventional garbage collection method will be described. <0-
1. Mark-and-sweep method> The mark-and-sweep method is disclosed in Japanese Patent Laid-Open Publication No. Hei 11-232162.
In this method, after all the cells that can be traced from the root pointer are marked, the cells are scanned and the unmarked cells are collected.

【0008】図27は、従来のマークアンドスイープ方
式を説明するための図である。同図では、アプリケーシ
ョンプログラムによってセルM1〜M7が生成された後
に、セルM3及びM5が不要となった状態を示してい
る。なお、同図中、セルを参照するポインタの所在部分
を起点とし、参照されるそのセルに向かう矢印線によっ
て、参照関係を表している。
FIG. 27 is a diagram for explaining the conventional mark-and-sweep method. In the figure, cells M3 and M5 are no longer needed after the cells M1 to M7 are generated by the application program. It should be noted that in the figure, a reference relationship is represented by an arrow line directed to the cell to be referred to, starting from the location of a pointer that refers to the cell.

【0009】ガベージコレクション機構は、カベージコ
レクションを開始すると、まず、ルートポインタRPか
ら直接又はセル内のポインタを介して、辿ることのでき
る全てのセルにマークを付ける。例えばセル内の管理用
の情報部分にマークの有無を表すビット領域を設けてお
き、初期値としてはマーク無しを表す値にしておき、マ
ークを付加する場合にそのビット領域をマーク有りを表
す値に変更する。
When the garbage collection mechanism starts garbage collection, it first marks all the cells that can be traced from the root pointer RP either directly or via pointers within cells. For example, a bit area indicating the presence or absence of a mark is provided in the management information part in a cell, and a value indicating no mark is set as an initial value. When adding a mark, the bit area indicates a value indicating the presence of a mark. Change to.

【0010】これにより、セルM1、M2、M4、M6
及びM7にはマーク(Mark)が付されることにな
る。その後に、ガベージコレクション機構は、マークの
付いていないセルを走査して解放する。なお、このマー
クの付いていないセルの走査の際に、ガベージコレクシ
ョン機構は、次回のガベージコレクションのために、マ
ークが付いているセルからマークを削除する処理も行
う。
As a result, the cells M1, M2, M4 and M6 are
And M7 will be marked. After that, the garbage collection mechanism scans and releases the unmarked cells. It should be noted that at the time of scanning the cells without marks, the garbage collection mechanism also performs the process of deleting the marks from the marked cells for the next garbage collection.

【0011】これにより、マークの付いていなかったセ
ルM3及びM5が検出され、このセルM3及びM5が解
放されることになる。このマークアンドスイープ方式に
よるガベージコレクションは全てのセルを走査するもの
であることから、頻繁に実行されると、アプリケーショ
ンプログラムの実行性能を著しく低下させる。このた
め、ガベージコレクション機構は、通常は、ある程度期
間をおいて、或いはアプリケーションプログラムと並行
して少しずつ、マークアンドスイープ方式によるガベー
ジコレクションを実行する。従って、必然的に、不要に
なったセルの回収が遅くなる。
As a result, the unmarked cells M3 and M5 are detected, and the cells M3 and M5 are released. Since the garbage collection by the mark-and-sweep method scans all cells, if it is frequently executed, the execution performance of the application program is significantly reduced. Therefore, the garbage collection mechanism normally executes the garbage collection by the mark-and-sweep method after a certain period of time or little by little in parallel with the application program. Therefore, inevitably, the collection of the unnecessary cells will be delayed.

【0012】<0-2.リファレンスカウント方式>リフ
ァレンスカウント方式は、セル毎にそのセルが何箇所か
ら参照されているかを示すカウント値(以下、「リファ
レンスカウンタ」という。)をセル内の管理用の情報部
分に記憶することとし、セルを指すポインタの変更等に
より参照関係が変化する度にそれに応じてリファレンス
カウンタを増加又は減少させ、リファレンスカウンタが
0になった時点でそのセルを回収する方式である。
<0-2. Reference Count Method> In the reference count method, a count value (hereinafter, referred to as a “reference counter”) indicating from where the cell is referenced is stored for each cell in a management information part in the cell. , The reference counter is incremented or decremented each time the reference relationship changes due to a change in the pointer pointing to a cell, and the cell is collected when the reference counter reaches zero.

【0013】具体的には、あるセル内のポインタが既に
いずれかのセルを指している場合において、アプリケー
ションプログラムの実行過程においてそのポインタの値
が他の値に変更されると、ガベージコレクション機構
が、元のポインタ値がNULLでない限り元のポインタ
値により指していたセル内のリファレンスカウンタを1
減少し、新たなポインタ値がNULLでない限り新たに
ポインタ値によって指すセル内のリファレンスカウンタ
を1増加する。
Specifically, when the pointer in a cell has already pointed to one of the cells and the value of the pointer is changed to another value during the execution process of the application program, the garbage collection mechanism causes , The reference counter in the cell pointed to by the original pointer value is set to 1 unless the original pointer value is NULL.
Decrement and increment the reference counter in the cell pointed to by the new pointer value by one unless the new pointer value is NULL.

【0014】こうして、ガベージコレクション機構は、
リファレンスカウンタが0になったセルについては、ル
ートポインタから辿ることのできなくなったもの即ち不
要なものとみなして解放する。なお、セルの解放の際に
そのセル内に含まれていたポインタはNULLに変更さ
れたものとして再帰的に、前述の、元のポインタ値がN
ULLでない限り元のポインタ値により指していたセル
内のリファレンスカウンタを1減少する処理を実行す
る。
Thus, the garbage collection mechanism is
A cell whose reference counter has become 0 is regarded as a cell that can no longer be traced from the root pointer, that is, an unnecessary cell, and is released. Note that the pointer contained in the cell when the cell is released is recursively changed to NULL, and the above-mentioned original pointer value is N.
Unless it is ULL, a process of decrementing the reference counter in the cell pointed by the original pointer value by 1 is executed.

【0015】図28は、従来のリファレンスカウント方
式を説明するための図である。同図は、状態901、状
態902、状態903の順に状態が遷移することを示し
ている。なお、同図中、セルを参照するポインタの所在
部分を起点とし、参照されるそのセルに向かう矢印線に
よって、参照関係を表しており、また、各セル内の数値
は、そのセルが参照されている数であるリファレンスカ
ウンタを示している。
FIG. 28 is a diagram for explaining a conventional reference counting method. The figure shows that the states transit in the order of state 901, state 902, and state 903. In the figure, the location where the pointer that refers to a cell is used as the starting point, and the arrow line that points to that cell indicates the reference relationship, and the numerical value in each cell refers to that cell. The reference counter, which is the number

【0016】状態901においては、同図では、アプリ
ケーションプログラムによってセルM1〜M7が使用さ
れている状態を示しており、セルM5はセルM4からの
み参照されているためセルM5のリファレンスカウンタ
は1である。この状態901は、アプリケーションプロ
グラムがいわゆる代入文等を実行してセルM4の保持す
るポインタを、セルM5を指す値から、セルM6を指す
値に変更すると、状態902に遷移する。このポインタ
の変更に際してガベージコレクション機構により、セル
M5のリファレンスカウンタが1減じられて0になり、
セルM6のリファレンスカウンタが1増やされ2にな
る。
In the state 901, in the figure, the cells M1 to M7 are used by the application program. Since the cell M5 is referenced only by the cell M4, the reference counter of the cell M5 is 1. is there. The state 901 transits to the state 902 when the application program executes a so-called assignment statement or the like to change the pointer held by the cell M4 from the value indicating the cell M5 to the value indicating the cell M6. When the pointer is changed, the reference counter of the cell M5 is decremented by 1 and becomes 0 by the garbage collection mechanism.
The reference counter of the cell M6 is incremented by 1 and becomes 2.

【0017】続いて、ガベージコレクション機構はリフ
ァレンスカウンタが0になったセルM5を解放し、セル
M5が保持していたポインタが指していたセルM3のリ
ファレンスカウンタを1減じて0にし、リファレンスカ
ウンタが0になったセルM3を解放する。状態903は
この結果を表している。リファレンスカウンタは、セル
が参照される可能性のある最大数を表現できるものでな
ければならないため、一般に1ワード程度の領域がリフ
ァレンスカウンタ用として用いられる。
Subsequently, the garbage collection mechanism releases the cell M5 whose reference counter has become 0, decrements the reference counter of the cell M3 pointed to by the pointer held by the cell M5 to 0, and sets the reference counter to 0. The cell M3 which has become 0 is released. State 903 represents this result. Since the reference counter must be capable of expressing the maximum number of cells that can be referenced, an area of about 1 word is generally used for the reference counter.

【0018】このリファレンスカウント方式によるガベ
ージコレクションは、基本的には不要になったセルを即
座に回収することができるという利点を有するが、セル
毎にリファレンスカウンタ用に1ワード程度の領域を要
するため全体ではガベージコレクションのみのために多
くのメモリ領域を必要とする欠点をも有する。なお、リ
ファレンスカウント方式には、セルへのポインタのチェ
ーンがループしている場合に、ルートポインタから辿る
ことのできなくなっているセルであるにも拘わらずリフ
ァレンスカウンタが0にならないため、その不要なセル
を解放できないという問題がある。この問題を解決する
ために、リファレンスカウント方式を用いる場合にはマ
ークアンドスイープ方式を併せて用いることもある。
The garbage collection by the reference counting method basically has an advantage that unnecessary cells can be immediately recovered, but each cell requires an area of about 1 word for a reference counter. It also has the drawback of requiring a large amount of memory space for garbage collection overall. In the reference counting method, when the chain of pointers to cells is looped, the reference counter does not become 0 even though the cell cannot be traced from the root pointer, so that unnecessary There is a problem that the cell cannot be released. In order to solve this problem, when the reference count method is used, the mark and sweep method may be used together.

【0019】<0-3.カウンタを制限したリファレンス
カウント方式>次に、リファレンスカウンタ用のメモリ
領域の縮小を図り上述のリファレンスカウント方式の欠
点を補った方式(以下、「カウンタ制限リファレンスカ
ウント方式」という。)について説明する。この方式
は、公開特許公報(特開平5−324456号)に開示
されている。
<0-3. Reference Counting Method with Limiting Counter> Next, a method (hereinafter, referred to as “counter limiting reference counting method”) in which the memory area for the reference counter is reduced to compensate for the above-mentioned drawbacks of the reference counting method will be described. This method is disclosed in Japanese Patent Laid-Open No. 5-324456.

【0020】カウンタ制限リファレンスカウント方式で
は、セル毎のリファレンスカウンタは0〜7を表すこと
ができる3ビットのみとし、基本的に上述のリファレン
スカウント方式と同様の処理手順を実行する。但し、リ
ファレンスカウンタがオーバフローしたセルについて
は、即ち参照される数が7を超えたセルについては、オ
ーバフローした時にリファレンスカウンタのビットを削
除した形に整形してガベージコレクションの対象外のメ
モリ領域にコピーするとともに、元のセルを解放する。
なお、ガベージコレクションの対象外のメモリ領域にお
いたセルについては、ガベージコレクション機構は、リ
ファレンスカウンタの操作やセルの回収を行わない。
In the counter-limited reference counting method, the reference counter for each cell has only 3 bits which can represent 0 to 7, and basically the same processing procedure as the above reference counting method is executed. However, when the reference counter overflows, that is, when the number of referenced cells exceeds 7, the reference counter bits are deleted when the overflow occurs and the cells are copied to a memory area that is not subject to garbage collection. At the same time, the original cell is released.
It should be noted that the garbage collection mechanism does not operate the reference counter or collect the cells in the cells in the memory area that is not the target of the garbage collection.

【0021】このカウンタ制限リファレンスカウント方
式によるガベージコレクションは、リファレンスカウン
タ用のビット数を抑えてはいるが、そのリファレンスカ
ウンタがオーバフローしたセルが増えると回収されない
セルが増加するため、アプリケーションプログラムが新
たにセルを確保することができない事態が発生し得ると
いう問題を有する。
Garbage collection by the counter limit reference counting method suppresses the number of bits for the reference counter, but if the number of cells overflowing the reference counter increases, the number of cells that cannot be collected increases. Therefore, the application program is newly added. There is a problem that a situation where a cell cannot be secured may occur.

【0022】[0022]

【発明が解決しようとする課題】上述したように、ガベ
ージコレクションにマークアンドスイープ方式のみを用
いる場合には、不要になったセルの回収が遅いという問
題が生じる。この問題を解決するリファレンスカウント
方式は、リファレンスカウンタ用に必要となるメモリ量
が大きいという欠点を有する。
As described above, when only the mark-and-sweep method is used for garbage collection, there arises a problem that the collection of unnecessary cells is slow. The reference counting method that solves this problem has a drawback in that the amount of memory required for the reference counter is large.

【0023】このリファレンスカウント方式の欠点をあ
る程度解消するカウンタ制限リファレンスカウント方式
は、使用されるセルのうち小数の例外を除く大部分のセ
ルについて、そのセルが参照される数がある程度小さ
く、1ワードに対して比較的少ないビット数でその参照
される数を表すことができる場合においては有効であ
る。
The counter-limited reference counting method, which eliminates the drawbacks of the reference counting method to some extent, has a small number of cells to be referred to for most of the cells used, with the exception of a small number of cells, to one word. Is effective when the referenced number can be represented by a relatively small number of bits.

【0024】しかしながら、カウンタ制限リファレンス
カウント方式は、大部分のセルの参照される数が、たと
え瞬間的にでも、非常に大きくなる場合には、その参照
される数を比較的少ないビット数で表そうとするとオー
バフローして大部分のセルが回収不可能なものになって
しまうためあまり有効ではない。以下、このような場合
の例を挙げる。
However, in the counter-limited reference counting method, when the reference number of most cells becomes very large even if it is instantaneous, the reference number is represented by a relatively small number of bits. This is not very effective, as it will overflow and render most cells irretrievable. An example of such a case will be given below.

【0025】図29は、Javaにおける典型的なセル
への参照数の時間的変化を示すグラフである。同図に示
すように、Java言語により作成された一般的なアプ
リケーションプログラムにおいては、オブジェクトを定
義するクラスが通常は複数階層にわたって他のクラスを
継承していることと関連して、オブジェクトの生成後の
初期化段階で、生成元のセルへの参照の数は急増し、初
期化が終わった後にはその生成元のセルへの参照ポイン
タを持つセルが消滅してゆき、その後の時間ではその生
成元のセルの参照される数は小さい値の範囲で微動す
る。
FIG. 29 is a graph showing the change over time in the number of references to a typical cell in Java. As shown in the figure, in a general application program created by the Java language, a class that defines an object is usually inherited from other classes over multiple hierarchies. During the initialization phase of, the number of references to the source cell increased rapidly, after the initialization the cell with the reference pointer to the source cell disappeared, and at a later time the The referenced number of the original cell fluctuates in the small value range.

【0026】このようなアプリケーションプログラムを
実行する場合においては、カウンタ制限リファレンスカ
ウント方式は、リファレンスカウンタとして小さいビッ
ト数を用いることができなくなるため、有効ではない。
そこで、本発明はかかる問題点に鑑みてなされたもので
あり、アプリケーションプログラムの動作によりセルの
参照される数が瞬間的に大きなピーク値をとるような場
合にも有効なガベージコレクション方法、及びその方法
を用いるガベージコレクション装置を提供することを目
的とする。
When executing such an application program, the counter-limited reference counting method is not effective because a small number of bits cannot be used as a reference counter.
Therefore, the present invention has been made in view of such problems, and a garbage collection method that is effective even when the number of cells referred to by the operation of an application program has a large peak value instantaneously, and the same It is an object to provide a garbage collection device using the method.

【0027】[0027]

【課題を解決するための手段】上記目的を達成するため
に、本発明に係るガベージコレクション装置は、アプリ
ケーションプログラムの実行によってメモリセルへの参
照状態が変更された時に、各メモリセル内に設けた被参
照カウンタを用いてリファレンスカウント方式によりガ
ベージコレクションを行うリファレンスカウント手段
と、アプリケーションプログラムの実行とは独立して1
以上のメモリセルについて、当該メモリセルが現実に参
照されている数を調査する独立カウント手段と、前記独
立カウント手段による調査結果である数を、対応するメ
モリセルの被参照カウンタに設定する設定手段とを備え
ることを特徴とする。
In order to achieve the above object, the garbage collection device according to the present invention is provided in each memory cell when the reference state to the memory cell is changed by the execution of the application program. Reference count means for performing garbage collection by the reference count method using the referenced counter and execution of the application program 1 independently
For the above memory cells, independent count means for checking the number of actually referenced memory cells, and setting means for setting the number of the check result by the independent count means in the referenced counter of the corresponding memory cell. And is provided.

【0028】また、本発明に係るガベージコレクション
方法は、アプリケーションプログラムの実行によってメ
モリセルへの参照状態が変更された時に、各メモリセル
内に設けられた被参照カウンタを用いてリファレンスカ
ウント方式によりガベージコレクションを行うリファレ
ンスカウントステップと、アプリケーションプログラム
の実行とは独立して1以上のメモリセルについて、当該
メモリセルが現実に参照されている数を調査する独立カ
ウントステップと、前記独立カウントステップによる調
査結果である数を、対応するメモリセルの被参照カウン
タに設定する設定ステップとを含むことを特徴とする。
Further, in the garbage collection method according to the present invention, when the reference state to the memory cell is changed by the execution of the application program, the referenced counter provided in each memory cell is used to perform the garbage collection by the reference count method. A reference count step of performing collection, an independent count step of checking the number of actually referenced memory cells in one or more memory cells independently of the execution of an application program, and a result of the check by the independent count step. And a setting step of setting a certain number to the referenced counter of the corresponding memory cell.

【0029】ここで、独立カウント手段及び独立カウン
トステップの説明中の「アプリケーションプログラムの
実行と独立して」とは、例えばアプリケーションプログ
ラム中のポインタ変更を指定するいわゆる代入のコード
等を契機として実行するのではないことを意味し、独立
カウント手段等による調査が、従来のリファレンスカウ
ント方式に含まれる動作ではないことを意味する。
Here, "independently of executing the application program" in the description of the independent counting means and the independent counting step is executed, for example, by a so-called assignment code or the like for designating pointer change in the application program. It means that the investigation by the independent counting means or the like is not an operation included in the conventional reference counting method.

【0030】セルの被参照数が、瞬間的に大きなピーク
値をとる等、時間経過につれて大きく変動するような場
合においては、被参照カウンタをピーク値が表せない程
度の小さなビット数で構成することとすると被参照カウ
ンタはオーバフローし無効となってしまうが、上記構成
により、現実にセルが参照されている数が調査されて被
参照カウンタにあらためて設定されることにより被参照
カウンタは正しい値に修正され得るため、その後にはリ
ファレンスカウント方式のガベージコレクションによっ
てポインタの変更に伴いセルがどこからも参照されなく
なった時点で即座にそのセルが解放されるようになる。
In the case where the number of referenced cells in the cell fluctuates greatly over time, such as a momentarily large peak value, the referenced counter should be configured with a small number of bits such that the peak value cannot be represented. Then, the referenced counter overflows and becomes invalid, but with the above configuration, the number of actually referenced cells is checked and set again in the referenced counter, so the referenced counter is corrected to the correct value. Therefore, after that, when the pointer is changed by the garbage collection of the reference count method and the cell is no longer referenced from anywhere, the cell is immediately released.

【0031】また、本発明に係る制御プログラムは、コ
ンピュータにガベージコレクション処理を行わせるため
の制御プログラムであって、前記ガベージコレクション
処理は、アプリケーションプログラムの実行によってメ
モリセルへの参照状態が変更された時に、各メモリセル
内に設けた被参照カウンタを用いてリファレンスカウン
ト方式によりガベージコレクションを行うリファレンス
カウントステップと、アプリケーションプログラムの実
行とは独立して1以上のメモリセルについて、当該メモ
リセルが現実に参照されている数を調査する独立カウン
トステップと、前記独立カウントステップによる調査結
果である数を、対応するメモリセルの被参照カウンタに
設定する設定ステップとを含むことを特徴とする。
Further, the control program according to the present invention is a control program for causing a computer to perform a garbage collection process, and in the garbage collection process, a reference state to a memory cell is changed by executing an application program. Sometimes, the reference count step of performing the garbage collection by the reference count method using the referenced counter provided in each memory cell, and the execution of the application program, independently of the execution of the application program, the memory cell is actually The present invention is characterized by including an independent counting step of investigating the referenced number and a setting step of setting the number, which is the investigative result of the independent counting step, in the referenced counter of the corresponding memory cell.

【0032】この制御プログラムをコンピュータにイン
ストールして実行することにより、上述のガベージコレ
クション方法が実現されるようになる。
By installing this control program in a computer and executing it, the above-mentioned garbage collection method can be realized.

【0033】[0033]

【発明の実施の形態】以下、本発明の実施の形態に係る
ガベージコレクション装置について説明する。 <1.実施の形態1> <1-1.構成>図1は、本発明の実施の形態1に係るガ
ベージコレクション装置100の構成図である。
BEST MODE FOR CARRYING OUT THE INVENTION A garbage collection apparatus according to an embodiment of the present invention will be described below. <1. Embodiment 1><1-1.Configuration> FIG. 1 is a configuration diagram of a garbage collection apparatus 100 according to the first embodiment of the present invention.

【0034】ガベージコレクション装置100は、CP
U、メモリ等を備えたコンピュータにおいてメモリに格
納された制御プログラムがCPUによって実行されるこ
とにより実現され、オペレーティングシステム上で動作
し、Java言語等で作成されたアプリケーションプロ
グラムの実行環境の一部として位置づけられるソフトウ
ェア的な装置である。
The garbage collection device 100 is a CP
As a part of an execution environment of an application program which is realized by the control program stored in the memory being executed by the CPU in a computer provided with U, a memory and the like, operates on the operating system, and is created in the Java language or the like. It is a software-like device that can be positioned.

【0035】なお、同図には、アプリケーションプログ
ラムの実行に際して、ガベージコレクション装置100
に指示を伝える制御機構200と、セルとして割り当て
られる領域を含むメモリ300とをも示している。制御
機構200は、アプリケーションプログラムの実行環境
の一部であり、アプリケーションプログラムの解釈、実
行等の実行制御を行い、アプリケーションプログラムに
よるポインタの変更をガベージコレクション装置100
に対して伝え、また、メモリ不足等を検出して後述する
カウントアンドスイープ処理の実行をガベージコレクシ
ョン装置100に要求する機構である。
In the figure, the garbage collection device 100 is used when the application program is executed.
Also shown is a control mechanism 200 for transmitting instructions to a memory and a memory 300 including areas allocated as cells. The control mechanism 200 is a part of the execution environment of the application program, performs execution control such as interpretation and execution of the application program, and changes the pointer by the application program.
In addition, it is a mechanism that requests the garbage collection device 100 to execute a count-and-sweep process, which will be described later, by detecting a memory shortage and the like.

【0036】この制御機構200は、セル確保部20
1、ポインタ設定部202及びカウントアンドスイープ
指示部210を備える。ここで、セル確保部201は、
アプリケーションプログラムの実行時におけるオブジェ
クトの生成に対応して、つまりアプリケーションプログ
ラム中のオブジェクト生成用のコードを解釈する際に、
メモリ300中の領域をそのオブジェクトのデータを格
納するセルとして確保する機能を有する。
The control mechanism 200 includes a cell securing section 20.
1, a pointer setting unit 202 and a count and sweep instruction unit 210. Here, the cell securing unit 201
Corresponding to the generation of the object at the time of execution of the application program, that is, when interpreting the code for generating the object in the application program,
It has a function of securing an area in the memory 300 as a cell for storing the data of the object.

【0037】セルは、そのセルが参照されている数、つ
まりそのセルを示すポインタの存在する数を示すリファ
レンスカウンタを保持している。このリファレンスカウ
ンタには、リファレンスカウント方式において通常用い
られるものであってアプリケーションプログラムによる
ポインタの変更に応じて変化させるべきリファレンスカ
ウンタAと、後述するカウントアンドスイープ処理にお
いてセルが参照されている数をカウントするために用い
られる独特のリファレンスカウンタBとの2種類があ
る。なお、セルのデータ構造については後に詳しく説明
する。
The cell holds a reference counter indicating the number of times the cell is referenced, that is, the number of pointers indicating the cell. This reference counter includes a reference counter A that is normally used in the reference counting method and should be changed according to the change of the pointer by the application program, and the number of cells referred to in the count and sweep processing described later. There are two types, a unique reference counter B used to do this. The cell data structure will be described later in detail.

【0038】ポインタ設定部202は、アプリケーショ
ンプログラムの実行時におけるポインタの変更に対応し
て、つまりアプリケーションプログラム中のオブジェク
トポインタへの代入のコードを解釈した際に、ポインタ
の変更をガベージコレクション装置100に対して伝え
る機能を有する。また、カウントアンドスイープ指示部
210は、メモリ不足を検出したとき、即ちメモリ30
0中において新たにセルを割り当てることのできるメモ
リ領域が減少していることを検出したときにガベージコ
レクション装置100に対してカウントアンドスイープ
処理の実行を要求する機能を有する。
The pointer setting unit 202 responds to the change of the pointer at the time of execution of the application program, that is, when interpreting the code of assignment to the object pointer in the application program, the change of the pointer is made to the garbage collection device 100. It has the function of communicating with other people. The count-and-sweep instruction unit 210 detects that the memory is insufficient, that is, the memory 30.
It has a function of requesting the garbage collection device 100 to execute the count-and-sweep process when it is detected that the memory area to which a new cell can be allocated decreases in 0.

【0039】ガベージコレクション装置100は、アプ
リケーションプログラムが実行中に確保したセルがどこ
からも参照されなくなっている場合にそのセルを解放す
る、いわゆるガベージコレクションをリファレンスカウ
ント方式を変形した方式により行う機能を有し、機能構
成要素として、カウンタ変更部110、カウンタゼロ判
定部120、セル解放部130、再カウント部140、
再カウント結果ゼロ判定部141及びカウンタ再設定部
142を備える。
The garbage collection device 100 has a function of performing so-called garbage collection by a modified version of the reference counting system, in which a cell secured during execution of an application program is released when the cell is no longer referenced. However, as the functional components, the counter changing unit 110, the counter zero determining unit 120, the cell releasing unit 130, the recounting unit 140,
A zero count result zero determination unit 141 and a counter reset unit 142 are provided.

【0040】ここで、カウンタ変更部110は、制御機
構200中のポインタ設定部202からのポインタの変
更の通知を受けた時にポインタ変更対応処理を実行する
ものであり、カウンタ最大値判定部111、カウンタ増
加部112及びカウンタ減少部113を有する。カウン
タ最大値判定部111は、セルのリファレンスカウンタ
が最大値になっているか否かを判定するものであり、カ
ウンタ増加部112は、セルのリファレンスカウンタを
1増加するものであり、カウンタ減少部113は、セル
のリファレンスカウンタを1減少するものである。
Here, the counter changing unit 110 executes the pointer change handling process when it receives the pointer change notification from the pointer setting unit 202 in the control mechanism 200. The counter maximum value judging unit 111, It has a counter increment unit 112 and a counter decrement unit 113. The counter maximum value determination unit 111 determines whether or not the reference counter of the cell has reached the maximum value, the counter increment unit 112 increments the reference counter of the cell by 1, and the counter decrement unit 113. Decrements the cell reference counter by one.

【0041】カウンタゼロ判定部120は、カウンタ減
少部113が減少したセルのリファレンスカウンタAが
0になっているか否かを判定し、0であればセル解放部
130にセルの解放を指示する機能を有する。セル解放
部130は、カウンタゼロ判定部120又は再カウント
結果ゼロ判定部141の指示を受けてセルの解放を行う
ものである。
The counter zero judging unit 120 judges whether or not the reference counter A of the cell decremented by the counter decrementing unit 113 is 0, and if it is 0, a function of instructing the cell releasing unit 130 to release the cell. Have. The cell releasing unit 130 releases a cell in response to an instruction from the counter zero determining unit 120 or the recount result zero determining unit 141.

【0042】再カウント部140は、カウントアンドス
イープ指示部210からカウントアンドスイープ処理の
実行要求を受けた時にカウントアンドスイープ処理の実
行を開始し、各セルが参照されている数をセルのリファ
レンスカウンタBを用いてカウントする機能を有する。
再カウント結果ゼロ判定部141は、再カウント部14
0によるカウントの結果として全てのセルのうちリファ
レンスカウンタBが0であるセルについては、セル解放
部130にそのセルの解放を指示し、リファレンスカウ
ンタBが0でないセルについては、カウンタ再設定部1
42にセルにおけるリファレンスカウンタの再設定指示
を伝える機能を有する。
The re-counting unit 140 starts the execution of the count-and-sweep process when it receives the count-and-sweep process execution request from the count-and-sweep instruction unit 210, and determines the number of cells referenced by the reference counter of the cell. It has a function of counting using B.
The zero count result zero determination unit 141
For cells whose reference counter B is 0 among all cells as a result of counting by 0, the cell releasing unit 130 is instructed to release the cell, and for cells whose reference counter B is not 0, the counter resetting unit 1
42 has a function of transmitting an instruction to reset the reference counter in the cell.

【0043】カウンタ再設定部142は、再設定指示が
伝えられたセルのリファレンスカウンタBの値をレファ
レンスカウンタAにコピーする機能を有する。 <1-2.データ>以下、ガベージコレクション装置10
0の処理対象となり、アプリケーションプログラムにお
けるオブジェクトのデータを格納するために用いられる
データ単位であるセルについて説明する。
The counter resetting unit 142 has a function of copying the value of the reference counter B of the cell to which the reset instruction is transmitted to the reference counter A. <1-2. Data> Below, garbage collection device 10
A cell which is a processing target of 0 and is a data unit used for storing data of an object in an application program will be described.

【0044】図2は、セルのデータ構造を示す図であ
る。なお、同図における1行は、計算機の基本語長とな
るワード単位に相当する。ここでは、1ワードが32ビ
ットであるものとして説明する。セル1100は、複数
ワードで構成され、1ワードのヘッダ部と、可変長のデ
ータ領域1106とからなる。
FIG. 2 is a diagram showing the data structure of a cell. It should be noted that one line in the figure corresponds to a word unit that is the basic word length of the computer. Here, it is assumed that one word has 32 bits. The cell 1100 is composed of a plurality of words and includes a 1-word header portion and a variable-length data area 1106.

【0045】ここで、ヘッダ部は、有効セルフラグ領域
1101とセル長領域1102とリファレンスカウンタ
A領域1103とリファレンスカウンタB領域1104
と作業フラグ領域1105とから構成される。有効セル
フラグ領域1101は、セルが有効か無効かを示す有効
セルフラグを格納するための1ビットの領域である。有
効セルフラグは、セルが有効であれば1、無効であれば
0の値をとる。有効セルフラグが0であるセルの領域
は、アプリケーションプログラムにおけるオブジェクト
の生成に対応してセル確保部201により、新たにセル
を割り当てられ得る領域となり、セル確保部201によ
り新たにセルが確保された際には有効セルフラグは1に
設定される。
Here, the header portion includes a valid cell flag area 1101, a cell length area 1102, a reference counter A area 1103, and a reference counter B area 1104.
And a work flag area 1105. The valid cell flag area 1101 is a 1-bit area for storing a valid cell flag indicating whether the cell is valid or invalid. The valid cell flag takes a value of 1 if the cell is valid and a value of 0 if the cell is invalid. The cell area in which the valid cell flag is 0 becomes an area in which a new cell can be allocated by the cell reserving section 201 in response to the generation of an object in the application program, and when the cell reserving section 201 newly reserves a cell. The valid cell flag is set to 1.

【0046】なお、セルの解放は有効セルフラグが1か
ら0に変更されることによって実現され、これにより、
その有効セルフラグを含むセルが割り当てられていたメ
モリ領域は、新たにセルを確保するために用いられ得
る、再利用可能な領域となる。セル長領域1102は、
ヘッダ部とデータ領域とを合わせたセル長を示す値を格
納する21ビットの領域である。この領域に格納される
セル長は、例えばワード数で表される。
Note that the cell release is realized by changing the valid cell flag from 1 to 0.
The memory area to which the cell including the valid cell flag is assigned becomes a reusable area that can be used to newly secure the cell. The cell length area 1102 is
It is a 21-bit area that stores a value indicating the cell length of the header portion and the data area. The cell length stored in this area is represented by the number of words, for example.

【0047】リファレンスカウンタA領域1103及び
リファレンスカウンタB領域1104は、リファレンス
カウンタA及びリファレンスカウンタBを格納する4ビ
ットずつの領域である。両リファレンスカウンタは0か
ら15までの数を表すことができるが、最大値である1
5は、セルが参照されている数が15以上に1度なって
しまったためにリファレンスカウンタがオーバフローし
ていることを示すものとして用いられる。リファレンス
カウンタに関してこの15という数を、以下、MAX値
とも表現する。
The reference counter A area 1103 and the reference counter B area 1104 are 4-bit areas for storing the reference counter A and the reference counter B, respectively. Both reference counters can represent numbers from 0 to 15, with a maximum value of 1
5 is used to indicate that the reference counter has overflowed because the number of times the cell is referenced is once more than 15. The number of 15 with respect to the reference counter is also referred to as a MAX value below.

【0048】作業フラグ領域1105は、カウントアン
ドスイープ処理においてセルに関する状態を3段階で示
すために用いられる作業フラグを格納する2ビットの領
域である。セルに関する状態は、ポインタにより参照さ
れていることが検出されていない状態(以下、「白色」
とも表現する。)と、そのセルがポインタにより参照さ
れていることが初めて検出された状態(以下、「灰色」
とも表現する。)と、そのセルが保持するポインタが示
すセルについてのリファレンスカウンタの操作を実行済
みである状態(以下、「黒色」とも表現する。)とであ
る。また、作業フラグの値が0であればセルが白色であ
ることを示し、1であればセルが灰色であることを示
し、2であればセルが黒色であることを示す。
The work flag area 1105 is a 2-bit area for storing a work flag used to indicate the state regarding the cell in three stages in the count and sweep process. The state related to the cell is the state in which it is not detected that it is referred to by the pointer (hereinafter, "white").
Is also expressed. ) And the state in which the cell is first referenced by a pointer (hereinafter referred to as “gray”).
Is also expressed. ) And a state in which the operation of the reference counter for the cell indicated by the pointer held by the cell has already been executed (hereinafter also referred to as “black”). If the value of the work flag is 0, the cell is white, if the value is 1, the cell is gray, and if the value is 2, the cell is black.

【0049】なお、後述のカウントアンドスイープ処理
においては、いわゆる三色アルゴリズムを用いており、
各セルは白色、灰色、黒色の順に変化することになる。
データ領域1106は、オブジェクトのデータを格納す
るための領域であり、この領域に、整数型、文字型、ポ
インタ型等のデータ型の情報が付された1又は複数のデ
ータが格納される。
In the count-and-sweep process described later, a so-called three-color algorithm is used,
Each cell will change in the order of white, gray, and black.
The data area 1106 is an area for storing object data, and in this area, one or a plurality of data to which data type information such as integer type, character type, pointer type, etc. is added is stored.

【0050】図3は、メモリ300の一部の領域にセル
が割り当てられている様子を示す図である。なお、同図
においてはポインタ型以外の型のデータを「変数」と表
現している。例えば、有効セル1201においては、有
効セルフラグが1であり、セル長が4ワードであり、リ
ファレンスカウンタAが2であり、リファレンスカウン
タBが0であり、作業フラグが0であり、ポインタ等を
含んでいる。
FIG. 3 is a diagram showing a state in which cells are assigned to a partial area of the memory 300. In the figure, data of types other than the pointer type are expressed as "variables". For example, in the valid cell 1201, the valid cell flag is 1, the cell length is 4 words, the reference counter A is 2, the reference counter B is 0, the work flag is 0, and a pointer and the like are included. I'm out.

【0051】また、有効セルフラグが0であるフリー領
域1211は3ワード分の領域であり、新たにセルとし
て確保され得る領域である。なお、この複数のセルが格
納されている領域において、セルを順次探索する場合に
は、先頭のセルから、セルのセル長を参照してそのセル
のサイズ分だけスキップすれば次のセルに至ることがで
きる。
The free area 1211 in which the valid cell flag is 0 is an area for 3 words and can be newly secured as a cell. In the area where the plurality of cells are stored, when sequentially searching for cells, the cell length of the cell is referred to from the first cell to skip the cell size to reach the next cell. be able to.

【0052】図4は、ある時点におけるセルの内容とセ
ル間の関係を例示した図である。同図においては、矢印
線の起点によりポインタの所在を示し、矢印の先端によ
りポインタの指すセルを示している。例えば、セル11
は、ルートポインタ10から指されており、かつ、セル
12を指すポインタとセル15を指すポインタとを含ん
でいることを示している。また、セル14は、どこから
も指されておらず、どこからも参照されていないことを
示している。
FIG. 4 is a diagram exemplifying the contents of cells and relationships between cells at a certain point of time. In the figure, the location of the pointer is indicated by the starting point of the arrow line, and the cell pointed by the pointer is indicated by the tip of the arrow. For example, cell 11
Indicates that it is pointed to by the root pointer 10 and includes a pointer pointing to the cell 12 and a pointer pointing to the cell 15. Further, the cell 14 is shown as not being pointed to by anywhere nor being referenced from anywhere.

【0053】<1-3.動作>以下、上述した構成を備
え、上述したセルを対象としたガベージコレクションを
行うガベージコレクション装置100と、これに関連
し、アプリケーションプログラムの解釈実行の制御を行
う制御機構200との動作について説明する。 <1-3-1.セルの生成>アプリケーションプログラムの
コードを逐次解釈し実行のための制御を行う制御機構2
00は、オブジェクト生成用のコードを解釈対象とした
ときに、セル確保部201によりセル生成処理を行う。
<1-3. Operation> Hereinafter, an operation of the garbage collection device 100 having the above-mentioned configuration and performing the garbage collection on the above-mentioned cell and the control mechanism 200 related to this, which controls the interpretation and execution of the application program will be described. . <1-3-1. Cell generation> Control mechanism 2 for sequentially interpreting application program code and controlling execution
00 causes the cell securing unit 201 to perform cell generation processing when the code for object generation is to be interpreted.

【0054】図5は、セル確保部201が行うセル生成
処理を示すフローチャートである。セル確保部201
は、セルに格納すべきオブジェクトのデータの量と、ヘ
ッダ部の1ワード分とを合わせたサイズのセルを確保
し、そのセルの有効セルフラグを1にし(ステップS4
11)、そのサイズに基づいてセル長を設定する(ステ
ップS412)。このセルの確保にあたり、セル確保部
201は、メモリ300中の有効セルフラグが0である
フリー領域を探索して、そのフリー領域の全部又は一部
を利用して新たにセルとして利用する。
FIG. 5 is a flowchart showing a cell generation process performed by the cell securing unit 201. Cell securing unit 201
Secures a cell having a size including the amount of object data to be stored in the cell and one word of the header portion, and sets the valid cell flag of the cell to 1 (step S4
11) and set the cell length based on the size (step S412). In reserving this cell, the cell reserving unit 201 searches for a free area in the memory 300 in which the valid cell flag is 0, and uses all or part of the free area as a new cell.

【0055】セル長を設定した後、セル確保部201
は、その確保したセルのリファレンスカウンタA及びB
を0とし、作業フラグを0にする(ステップS41
3)。これによりセルは白色となる。アプリケーション
プログラムにおけるオブジェクト生成用のコードにおい
て、通常は生成したオブジェクトを指すようにオブジェ
クトポインタへの代入が示されており、この場合におい
ては、ステップS413の後に、制御機構200はポイ
ンタ設定部202によりポインタの変更をガベージコレ
クション装置100に伝えて、ポインタ変更対応処理を
行わせることになる(ステップS414)。
After setting the cell length, the cell securing unit 201
Are the reference counters A and B of the secured cells.
To 0 and the work flag to 0 (step S41
3). This makes the cell white. In the code for generating an object in the application program, assignment to the object pointer is usually indicated so as to point to the generated object. In this case, after step S413, the control mechanism 200 causes the pointer setting unit 202 to set the pointer. Is sent to the garbage collection apparatus 100 to cause pointer change handling processing to be performed (step S414).

【0056】<1-3-2.ポインタの変更>制御機構20
0は、アプリケーションプログラムにおけるオブジェク
トポインタへの代入のコードを解釈対象としたときにポ
インタ設定部202を通じてポインタの変更をガベージ
コレクション装置100に伝える。なお、ポインタ設定
部202は、ポインタの変更を伝える際に、変更前後の
ポインタの値をも伝える。
<1-3-2. Change of pointer> Control mechanism 20
0 notifies the garbage collection device 100 of the pointer change through the pointer setting unit 202 when the code of assignment to the object pointer in the application program is to be interpreted. The pointer setting unit 202 also transmits the pointer values before and after the change when transmitting the pointer change.

【0057】ガベージコレクション装置100は、ポイ
ンタの変更が伝えられるとポインタ変更対応処理を行
う。図6は、ガベージコレクション装置100の行うポ
インタ変更対応処理を示すフローチャートである。ポイ
ンタの変更が伝えられると、ガベージコレクション装置
100のカウンタ変更部110は、変更前のポインタが
セルを指すか否かを判定し(ステップS421)、セル
を指すものである場合には、その着目している変更前の
ポインタに基づいてセル参照解除処理を行い(ステップ
S422)、セルを指すものでない場合にはステップS
422のセル参照解除処理は行わない。つまり変更前の
ポインタがNULLであればセル参照解除処理は行わな
い。なお、セル参照解除処理については後に図7を用い
て説明する。
The garbage collection device 100 performs pointer change handling processing when the pointer change is notified. FIG. 6 is a flowchart showing a pointer change handling process performed by the garbage collection device 100. When the pointer change is transmitted, the counter changing unit 110 of the garbage collection device 100 determines whether or not the pointer before the change points to the cell (step S421). The cell reference cancellation processing is performed based on the current pointer before change (step S422), and if it does not point to the cell, step S422
The cell reference cancellation processing of 422 is not performed. That is, if the pointer before the change is NULL, the cell reference cancellation processing is not performed. The cell reference cancellation processing will be described later with reference to FIG. 7.

【0058】続いて、カウンタ変更部110は、変更後
のポインタがセルを指すか否かを判定し(ステップS4
23)、セルを指すものでない場合にはポインタ変更対
応処理を終了する。また、ステップS423において、
変更後のポインタがセルを指すものである場合には、カ
ウンタ変更部110はカウンタ最大値判定部111によ
りそのポインタの指すセルのリファレンスカウンタAが
MAX値であるか否かを判定し(ステップS424)、
MAX値でない場合にはカウンタ増加部112にうより
そのリファレンスカウンタAを1増やし(ステップS4
25)、MAX値である場合にはステップS425は行
わない。
Subsequently, the counter changing unit 110 determines whether or not the changed pointer points to the cell (step S4).
23) If the pointer does not point to a cell, the pointer change handling process ends. Also, in step S423,
When the changed pointer points to the cell, the counter changing unit 110 determines whether the reference counter A of the cell pointed to by the pointer is the MAX value by the counter maximum value determining unit 111 (step S424). ),
If it is not the MAX value, the reference counter A is incremented by 1 by the counter incrementing unit 112 (step S4).
25), and if it is the MAX value, step S425 is not performed.

【0059】ステップS425の後に、或いはステップ
S424でMAX値であると判定した場合に、カウンタ
変更部110はその変更後のポインタを保持するセルの
作業フラグは2であるか否か、即ちそのセルが黒色であ
るか否かを判定し(ステップS426)、黒色でない場
合にはポインタ変更対応処理を終了する。ステップS4
26においてセルが黒色であると判定した場合には、カ
ウンタ変更部110は、その変更後のポインタが指すセ
ルの作業フラグは0であるか否か、即ちそのセルが白色
であるか否かを判定し(ステップS427)、白色であ
る場合に限りその変更後のポインタが指すセルの作業フ
ラグを0から1に変更する(ステップS428)。
After step S425 or when it is determined in step S424 that the value is the MAX value, the counter changing unit 110 determines whether the work flag of the cell holding the changed pointer is 2, that is, the cell. Is determined to be black (step S426), and if it is not black, the pointer change handling process ends. Step S4
When it is determined that the cell is black in 26, the counter changing unit 110 determines whether the work flag of the cell pointed by the changed pointer is 0, that is, whether the cell is white. The determination is made (step S427), and only when it is white, the work flag of the cell pointed by the changed pointer is changed from 0 to 1 (step S428).

【0060】ステップS427、S428に続いて、カ
ウンタ変更部110はカウンタ最大値判定部111によ
り、変更後のポインタの指すセルのリファレンスカウン
タBがMAX値であるか否かを判定し(ステップS42
9)、MAX値でない場合にはカウンタ増加部112に
よりそのリファレンスカウンタBを1増やして(ステッ
プS430)、ポインタ変更対応処理を終了し、MAX
値である場合にはステップS430を行わずにポインタ
変更対応処理を終了する。
Subsequent to steps S427 and S428, the counter changing unit 110 causes the counter maximum value judging unit 111 to judge whether or not the reference counter B of the cell pointed by the changed pointer is the MAX value (step S42).
9) If it is not the MAX value, the counter incrementing unit 112 increments the reference counter B by 1 (step S430), the pointer change handling process is terminated, and MAX is reached.
If it is a value, the pointer change handling process is terminated without performing step S430.

【0061】図7は、ガベージコレクション装置100
の行うセル参照解除処理を示すフローチャートである。
なお、同図ではステップS435においてセル参照解除
処理を再帰的に実行するように表現している。まず、カ
ウンタ変更部110は、セル参照解除処理を行う直前に
着目していたポインタに基づき、カウンタ最大値判定部
111により、その着目していたポインタの指すセルの
リファレンスカウンタAはMAX値であるか否かを判定
する(ステップS431)。
FIG. 7 shows a garbage collection apparatus 100.
6 is a flowchart showing a cell reference cancellation process performed by the above.
In the figure, in step S435, the cell reference cancellation processing is expressed recursively. First, the counter changing unit 110 causes the counter maximum value determining unit 111 to determine the reference counter A of the cell pointed to by the focused pointer is the MAX value based on the pointer focused on immediately before the cell dereference processing. It is determined whether or not (step S431).

【0062】以下、セル参照解除処理のステップS43
1を行う時点で着目していたポインタを処理対象ポイン
タということとする。ステップS431において、処理
対象ポインタの指すセルのリファレンスカウンタAがM
AX値でないと判定した場合には、カウンタ変更部11
0は、カウンタ減少部113によりそのリファレンスカ
ウンタAを1減らし(ステップS432)、続いてカウ
ンタゼロ判定部120は、そのリファレンスカウンタA
が0になったか否かを判定する(ステップS433)。
Hereinafter, step S43 of the cell reference cancellation processing.
The pointer that is focused on when 1 is performed is referred to as a processing target pointer. In step S431, the reference counter A of the cell pointed to by the processing target pointer is set to M.
When it is determined that the value is not the AX value, the counter changing unit 11
For 0, the counter decrement unit 113 decrements the reference counter A by 1 (step S432), and then the counter zero determination unit 120 determines the reference counter A.
Is determined to be 0 (step S433).

【0063】ステップS433において、リファレンス
カウンタAが0になっていると判定された場合には、処
理対象ポインタの指すセルの保持する、セルへのポイン
タに順次着目してセル参照解除処理(図7)を繰り返す
(ステップS434、S435)。これにより、処理対
象ポインタの指すセルが保持する、セルへのポインタの
数だけステップS435が繰り返されることになる。な
お、処理対象ポインタの指すセルが、セルへのポインタ
を保持しない場合にはステップS435の処理は省略さ
れる。
If it is determined in step S433 that the reference counter A is 0, the cell dereference process (FIG. 7) is performed by sequentially focusing on the pointers to the cells held by the cells pointed to by the process target pointer. ) Is repeated (steps S434 and S435). As a result, step S435 is repeated by the number of pointers to the cell held by the cell pointed to by the processing target pointer. If the cell pointed to by the processing target pointer does not hold the pointer to the cell, the process of step S435 is omitted.

【0064】セル解放部130は、ステップS433に
おいてリファレンスカウンタAが0になっていると判定
されたセルについて、ステップS435の繰り返しの後
に、有効セルフラグを0にすることによりセルを解放し
(ステップS436)、これによりセル参照解除処理は
終了する。また、ステップS431において処理対象ポ
インタの指すセルのリファレンスカウンタAがMAX値
であると判定した場合、及びステップS433において
リファレンスカウンタAが0になっていないと判定した
場合には、カウンタ変更部110は、処理対象ポインタ
を保持するセルが黒色か否かを判定し(ステップS43
7)、黒色でない場合にはセル参照解除処理を終了し、
黒色である場合には、カウンタ最大値判定部111によ
りその黒色のセルのリファレンスカウンタBがMAX値
であるか否かを判定する(ステップS438)。
The cell releasing unit 130 releases the cell by setting the valid cell flag to 0 after repeating step S435 for the cell for which the reference counter A is determined to be 0 in step S433 (step S436). ), Thereby ending the cell reference cancellation processing. Further, when it is determined in step S431 that the reference counter A of the cell pointed to by the processing target pointer is the MAX value, and when it is determined in step S433 that the reference counter A is not 0, the counter changing unit 110 , It is determined whether or not the cell holding the processing target pointer is black (step S43).
7) If it is not black, end the cell reference cancellation processing,
If it is black, the counter maximum value determination unit 111 determines whether or not the reference counter B of the black cell has the MAX value (step S438).

【0065】ステップS438において、リファレンス
カウンタBがMAX値でないと判定した場合にはカウン
タ変更部110は、カウンタ減少部113によりそのリ
ファレンスカウンタBを1減らして(ステップS43
9)、セル参照解除処理を終了し、MAX値であると判
定した場合にはステップS439を行わずにセル参照解
除処理を終了する。
When it is determined in step S438 that the reference counter B is not the MAX value, the counter changing unit 110 decrements the reference counter B by 1 by the counter decrementing unit 113 (step S43).
9) If the cell reference cancellation processing is ended and it is determined that the value is the MAX value, the cell reference cancellation processing is ended without performing step S439.

【0066】<1-3-3.カウントアンドスイープ処理>
制御機構200のカウントアンドスイープ指示部210
は、単位時間当たりにおいて、CPUがアプリケーショ
ンプログラムの実行に割り当てられる時間に対して比較
的少ない時間を用いて、メモリ300中において新たに
セルを割り当てることのできるメモリ領域が予め定めた
基準量より減少しているか否かの検出を行って、減少し
ている場合にはその比較的少ない時間を用いてガベージ
コレクション装置100にカウントアンドスイープ処理
を行わせるよう制御する。なお、時間の割り当てに関し
ては、例えば、カウントアンドスイープ処理やこれに付
随した処理を、アプリケーションプログラムとは別スレ
ッドとして構成し、スレッド毎のいわゆるタイムスライ
ス値を適切に配分すること等によって実現できる。
<1-3-3. Count and sweep processing>
Count-and-sweep instruction unit 210 of control mechanism 200
Is a relatively small amount of time per unit time for the CPU to execute the application program, and the memory area in the memory 300 where new cells can be allocated is reduced from a predetermined reference amount. Whether or not it is detected is detected, and if it is decreased, the garbage collection device 100 is controlled to perform the count and sweep process using the relatively short time. Note that the time allocation can be realized by, for example, configuring the count-and-sweep processing and the processing associated therewith as a thread separate from the application program, and appropriately distributing a so-called time slice value for each thread.

【0067】図8は、ガベージコレクション装置100
の行うカウントアンドスイープ処理を示すフローチャー
トである。カウントアンドスイープ指示部210からカ
ウントアンドスイープ処理の実行が要求されると、ガベ
ージコレクション装置100の再カウント部140は、
まず全てのセルについてのリファレンスカウンタBを0
にして作業フラグを0にする(ステップS501)。こ
れにより全てのセルが白色になる。
FIG. 8 shows a garbage collection system 100.
It is a flow chart which shows the count and sweep processing which is performed. When the count-and-sweep instruction unit 210 requests execution of the count-and-sweep process, the re-count unit 140 of the garbage collection device 100
First, the reference counter B for all cells is set to 0.
And the work flag is set to 0 (step S501). This makes all cells white.

【0068】ステップS501に続いて、再カウント部
140は、ルートポインタから直接指されている全ての
セルについて、作業フラグを1にしてセルを灰色にする
とともに、リファレンスカウンタBがMAX値でなけれ
ばリファレンスカウンタBを1増やす(ステップS50
2)。ステップS502に続いて、再カウント部140
は、ルートポインタに端を発するポインタチェーンを辿
って、灰色のセルを探索する(ステップS503)。
Subsequent to step S501, the recount unit 140 sets the work flag to 1 for all cells directly pointed to by the root pointer to make the cells gray, and the reference counter B is not the MAX value. The reference counter B is incremented by 1 (step S50
2). Following step S502, the recount unit 140
Searches for a gray cell by following a pointer chain originating from the root pointer (step S503).

【0069】再カウント部140はステップS503の
探索の結果として、灰色のセルを探索できた場合には
(ステップS504)、探したその灰色のセル内におけ
るポインタであってセルを指すもの毎に、そのポインタ
が指すセルが白色ならば、そのセルの作業フラグを0か
ら1に変更することによってその白色のセルを灰色にす
るステップS506と、そのポインタが指すセルのリフ
ァレンスカウンタBがMAX値でなければリファレンス
カウンタBを1増やすステップS507とを繰り返し行
う(ステップS505〜S507)。但し、探した灰色
のセル内にセルを指すポインタがない場合にはステップ
S506及びS507の処理は省略する。
As a result of the search in step S503, the recounting unit 140 finds a gray cell (step S504). For each pointer in the gray cell that is searched for and pointing to the cell, If the cell pointed to by the pointer is white, step S506 that makes the white cell gray by changing the work flag of the cell from 0 to 1 and the reference counter B of the cell pointed to by the pointer must be the MAX value. For example, step S507 of incrementing the reference counter B by 1 is repeated (steps S505 to S507). However, if there is no pointer pointing to the cell in the gray cell that has been searched for, the processing of steps S506 and S507 is omitted.

【0070】探したその灰色のセル内のポインタ毎にス
テップS505により、ステップS506及びS507
を繰り返し行った後に、再カウント部140は、その灰
色のセルを黒色にし(ステップS508)、ステップS
503の処理に戻る。即ち、また別の灰色のセルの探索
を開始する。こうしてステップS503〜S508が繰
り返され、灰色のセルが存在しなくなった場合には、再
カウント部140は、ステップS504においてnoの
分岐に進み、全てのセルについてセル毎にステップS5
09〜S512を行う(ステップS509)。即ち、再
カウント部140は、全てのセルそれぞれについて順
次、再カウント結果ゼロ判定部141により、セルのリ
ファレンスカウンタBが0であるか否かを判定し(ステ
ップS510)、0でない場合には、カウンタ再設定部
142がセルのリファレンスカウンタAをリファレンス
カウンタBと同じ値にするとともにセルを白色にし(ス
テップS512)、0である場合にはセル解放部130
がそのセルの有効セルフラグを0にしてセルを解放する
(ステップS511)。こうして全てのセルについてス
テップS509以後の処理が行われると、カウントアン
ドスイープ処理は完了する。
For each pointer in the gray cell that has been found, steps S506 and S507 are performed by step S505.
After repeating, the recount unit 140 turns the gray cell into black (step S508),
Return to the processing of 503. That is, the search for another gray cell is started. In this way, steps S503 to S508 are repeated, and when the gray cell does not exist, the recount unit 140 proceeds to no branch in step S504, and steps S5 to S5 for all cells.
09-S512 are performed (step S509). That is, the recount unit 140 sequentially determines for each cell by the recount result zero determination unit 141 whether or not the reference counter B of the cell is 0 (step S510). The counter resetting unit 142 sets the reference counter A of the cell to the same value as the reference counter B and makes the cell white (step S512), and when it is 0, the cell releasing unit 130.
Resets the valid cell flag of the cell to 0 and releases the cell (step S511). When the processing from step S509 is performed on all cells in this way, the count and sweep processing is completed.

【0071】なお、カウントアンドスイープ処理は、ア
プリケーションプログラムの実行と並行して行われる。
但し、カウンタアンドスイープ処理は、図8に示す単一
ステップの実行中においてはアプリケーションプログラ
ムが実行されないようにし、さらにステップS505の
実行開始からステップS508の実行終了までの間にお
いてもアプリケーションプログラムが実行されないよう
にされる必要がある。これは、例えば、マルチタスク制
御を行うOSに対して、ガベージコレクション装置10
0が単一ステップやステップS505〜S508の実行
中はCPUを専有することを宣言する等によって実現さ
れる。
The count and sweep process is performed in parallel with the execution of the application program.
However, in the counter-and-sweep process, the application program is not executed during the execution of the single step shown in FIG. 8, and the application program is not executed between the start of execution of step S505 and the end of execution of step S508. Needs to be done. This is, for example, for the OS performing multitask control, the garbage collection device 10
0 is realized by declaring that the CPU occupies a single step or during execution of steps S505 to S508.

【0072】以下、上述したカウントアンドスイープ処
理の進行を図9〜図13を用いて段階を追って説明す
る。図9は、カウントアンドスイープ処理におけるステ
ップS502の終了直後のセルの内容とセル間の関係を
例示した図である。ここでは、説明を簡単にするために
6つのセルのみを示している。
The progress of the above count and sweep process will be described below step by step with reference to FIGS. 9 to 13. FIG. 9 is a diagram exemplifying the content of cells and the relationship between cells immediately after the end of step S502 in the count and sweep process. Only six cells are shown here for ease of explanation.

【0073】カウントアンドスイープ処理の実行前にお
いては、セル11〜16はいずれも有効セルフラグは1
で有効を示しており、セル11、セル13、セル14及
びセル16のリファレンスカウンタAはMAX値になっ
ており、セル12及びセル15のリファレンスカウンタ
Aは1であるものとする。同図に示す状態は、カウント
アンドスイープ処理のステップS501により、まずセ
ル11〜16の全てについて、リファレンスカウンタB
が0にされるとともに作業フラグが0にされた後、ステ
ップS502により、ルートポインタ10から直接指さ
れているセル11のリファレンスカウンタBが1に増や
され作業フラグが1にされた時点の状態である。この時
にはセル11のみが灰色であって、セル12〜16は白
色である。
Before execution of the count and sweep process, all the cells 11 to 16 have the valid cell flag set to 1.
Is valid, the reference counter A of the cell 11, the cell 13, the cell 14, and the cell 16 has the MAX value, and the reference counter A of the cell 12 and the cell 15 is 1. In the state shown in the figure, the reference counter B is first set for all the cells 11 to 16 by step S501 of the count and sweep process.
Is set to 0 and the work flag is set to 0. Then, in step S502, the reference counter B of the cell 11 directly pointed to by the root pointer 10 is increased to 1 and the work flag is set to 1. is there. At this time, only the cell 11 is gray and the cells 12 to 16 are white.

【0074】図10は、カウントアンドスイープ処理に
おける1回目のステップS508の実行の終了直後のセ
ルの内容とセル間の関係を例示した図である。同図に示
す状態は、図9に示す状態を前提として、ステップS5
03により灰色のセル11が探知されてそのセル内のポ
インタが指すセル12及びセル15について白色から灰
色に変えられリるとともにファレンスカウンタBを1増
やされ(ステップS504〜S507)、ステップS5
08によりセル11を黒色にされた時点の状態である。
FIG. 10 is a diagram exemplifying the content of cells and the relationship between cells immediately after the completion of the first execution of step S508 in the count and sweep process. The state shown in the figure is based on the state shown in FIG.
The gray cell 11 is detected by 03, and the cells 12 and 15 pointed by the pointers in the cell are changed from white to gray, and the reference counter B is incremented by 1 (steps S504 to S507), and step S5.
This is the state at the time when the cell 11 is made black by 08.

【0075】図11は、カウントアンドスイープ処理に
おける2回目のステップS508の実行の終了直後のセ
ルの内容とセル間の関係を例示した図である。同図に示
す状態は、図10に示す状態を前提として、ステップS
503により灰色のセル12が探知されてそのセル内の
ポインタが指すセル13及びセル16について白色から
灰色に変えられるとともにリファレンスカウンタBを1
増やされ(ステップS504〜S507)、ステップS
508によりセル12を黒色にされた時点の状態であ
る。
FIG. 11 is a diagram exemplifying the contents of cells and the relationship between cells immediately after the execution of the second step S508 in the count and sweep process is completed. The state shown in the figure is based on the state shown in FIG.
The gray cell 12 is detected by 503, and the cells 13 and 16 pointed by the pointers in the cell are changed from white to gray and the reference counter B is set to 1
Increased (steps S504 to S507), step S
This is the state at the time when the cell 12 is made black by 508.

【0076】図12は、カウントアンドスイープ処理に
おいてS504のnoの分岐に進んだ直後のセルの内容
とセル間の関係を例示した図である。同図に示す状態
は、図11に示す状態を前提として、ステップS503
〜S508の処理を繰り返し行うことにより、灰色のセ
ルが存在しなくなった時点の状態である。この時、各セ
ルはそのセルが参照されている数をリファレンスカウン
タBにより示すことになる。
FIG. 12 is a diagram exemplifying the contents of cells and the relationship between cells immediately after proceeding to the no branch of S504 in the count and sweep processing. The state shown in the figure is based on the state shown in FIG.
This is the state at the time when the gray cell is no longer present by repeating the processing from S508 to S508. At this time, each cell indicates the number of times the cell is referenced by the reference counter B.

【0077】図13は、カウントアンドスイープ処理の
終了時点のセルの内容とセル間の関係を例示した図であ
る。同図に示す状態は、図12に示す状態を前提とし
て、ステップS509〜S511が実行されることによ
り、リファレンスカウンタBが0であったセル14は有
効セルフラグが1から0にされて解放され、他のセルに
ついてはリファレンスカウンタBがリファレンスカウン
タAにコピーされた状態である。このカウントアンドス
イープ処理により、どこからも参照されていないセル1
4の解放が行われ、また、一旦15回以上も参照された
ことによってMAX値になっていたリファレンスカウン
タAがセルの現在の被参照回数を示す値になおされた。
従って、以後はポインタ変更対応処理において、リファ
レンスカウンタAに基づき、リファレンスカウンタAが
0になった時点でセルの解放を行うことができるように
なる。
FIG. 13 is a diagram exemplifying the contents of cells and the relationship between cells at the end of the count and sweep process. The state shown in the figure is based on the state shown in FIG. 12, and by executing steps S509 to S511, the valid cell flag of the cell 14 whose reference counter B is 0 is released from 1 to 0, The reference counter B is copied to the reference counter A for the other cells. By this count and sweep process, cell 1 that is not referenced from anywhere
4 is released, and the reference counter A, which has been at the MAX value due to the reference being made 15 times or more, is reset to a value indicating the current number of times of reference to the cell.
Therefore, thereafter, in the pointer change handling process, the cell can be released based on the reference counter A when the reference counter A becomes 0.

【0078】<1-4.考察>セルの生存期間における被
参照数の経時的変化について考えると、セルへの参照数
は、図29に示したようにセルの生成から短い時間にお
いては、例えば300回等とリファレンスカウンタで表
せない大きな値になり得るが、いずれは、例えば10回
前後等とリファレンスカウンタで表せる大きさに落ち着
く。
<1-4. Consideration> Considering the change over time in the number of referenced cells in the cell lifetime, the number of cell references can be represented by a reference counter, for example, 300 times in the short time after cell generation, as shown in FIG. Although it may take a large value, it will eventually settle to a size that can be represented by a reference counter, such as around 10 times.

【0079】即ち、Java言語等、可変長のデータ構
造を有するオブジェクトを生成可能とするタイプのプロ
グラミング言語で作成されたアプリケーションプログラ
ムにおいて、そのオブジェクトの生成に対応してメモリ
中において確保されるセルは、図29に示したように確
保から短期間においては一旦リファレンスカウンタAが
オーバフローするほど多数の参照がなされるが、その後
にはそのセルが参照される数はリファレンスカウンタA
がオーバフローしない程度に落ち着く。
That is, in an application program created in a programming language of a type capable of creating an object having a variable-length data structure, such as Java language, the cells secured in the memory corresponding to the creation of the object are As shown in FIG. 29, a large number of references are made so that the reference counter A once overflows within a short period from the securing, but after that, the number of references to that cell is the reference counter A.
Settles down to the extent that does not overflow.

【0080】従って、セルの生成から短い時間において
はリファレンスカウンタAがMAX値に一旦なってしま
うが、いずれ落ち着いた段階でカウントアンドスイープ
処理が行われることにより、その時点でのセルの被参照
数がリファレンスカウンタAに再設定されるため、その
後は、通常のリファレンスカウンタ方式による場合と同
様に、そのセルがどこからも参照されなくなった時に即
座にそのセルの解放を行うような制御を実現することが
可能になる。
Therefore, the reference counter A temporarily reaches the MAX value in a short time after the generation of cells, but the count-and-sweep processing is performed at a stable stage, so that the number of referenced cells in the cell at that time is decreased. Is reset to the reference counter A, and thereafter, similar to the case of the normal reference counter method, control to immediately release the cell when the cell is no longer referenced from anywhere is realized. Will be possible.

【0081】このカウントアンドスイープ処理によれ
ば、どこからも参照されておらず不要となっているセル
を解放するマークアンドスイープ方式と同様の効果に加
えて、リファレンスカウンタが一旦オーバフローしてリ
ファレンスカウント方式に相当する解放制御が不可能に
なったセルであっても、その処理時点においてそのセル
の被参照数がリファレンスカウンタで表せる範囲内に収
まっていれば、以後そのセルについて、リファレンスカ
ウント方式と同様なセルの解放制御を行うことができる
ようになるという効果が得られる。
According to this count-and-sweep processing, in addition to the effect similar to the mark-and-sweep method of releasing unnecessary cells that are not referenced from anywhere, the reference counter once overflows and becomes a reference count method. Even if a cell for which the release control corresponding to the above becomes impossible, if the number of referenced cells of the cell falls within the range that can be represented by the reference counter at the time of processing, that cell is thereafter referred to as the reference count method. The effect that it becomes possible to perform the release control of various cells is obtained.

【0082】なお、この実施の形態1で示した方式を、
従来の単なるリファレンスカウント方式と対比すると、
実施の形態1で示した方式は、セルの被参照数の初期段
階でのピーク値と後の安定状態における値との格差が大
きいときには、リファレンスカウントのために必要なセ
ル内の領域を、より小さいものにできる可能性をもつ方
式であるといえる。 <2.実施の形態2>以下、本発明の実施の形態2に係
るガベージコレクション装置(以下、「変形ガベージコ
レクション装置」という。)について説明する。
The method shown in the first embodiment is
Compared with the conventional simple reference count method,
In the method described in the first embodiment, when there is a large difference between the peak value of the number of cells referred to in the initial stage and the value in the subsequent stable state, the area in the cell required for reference counting is more It can be said that this method has the potential to be small. <2. Second Preferred Embodiment> Hereinafter, a garbage collection device according to a second preferred embodiment of the present invention (hereinafter, referred to as “deformed garbage collection device”) will be described.

【0083】<2-1.構成>変形ガベージコレクション
装置は、実施の形態1において説明したガベージコレク
ション装置100と基本的な構成は同じであるが、セル
内に作業用領域を設けてその作業用領域を利用すること
によりカウントアンドスイープ処理をより高速に行える
ようにしたものである。以下、変形ガベージコレクショ
ン装置の機能構成要素についてはガベージコレクション
装置100の機能構成要素と同じ符号を用いて説明する
(図1参照)。また、この変形ガベージコレクション装
置に対応し、実施の形態1に示した制御機構200に相
当する制御機構を変形制御機構といい、その機能構成要
素については制御機構200の機能構成要素と同じ符号
を用いて説明する。
<2-1. Configuration> The modified garbage collection device has the same basic configuration as the garbage collection device 100 described in the first embodiment, but counts and counts by providing a work area in a cell and using the work area. The sweep process can be performed at higher speed. The functional components of the modified garbage collection device will be described below using the same reference numerals as the functional components of the garbage collection device 100 (see FIG. 1). Further, a control mechanism corresponding to the modified garbage collection device and corresponding to the control mechanism 200 shown in the first embodiment is referred to as a modification control mechanism, and the functional components thereof have the same reference numerals as the functional components of the control mechanism 200. It demonstrates using.

【0084】<2-2.データ>以下、変形ガベージコレ
クション装置の処理対象となり、アプリケーションプロ
グラムにおけるオブジェクトのデータを格納するために
用いられるデータ単位であるセルについて説明する。図
14は、変形ガベージコレクション装置が取り扱うセル
のデータ構造を示す図である。なお、同図における1行
は、計算機の基本語長となるワード単位に相当する。
<2-2. Data> Hereinafter, a cell which is a processing target of the modified garbage collection device and which is a data unit used for storing data of an object in an application program will be described. FIG. 14 is a diagram showing a data structure of cells handled by the modified garbage collection device. It should be noted that one line in the figure corresponds to a word unit that is the basic word length of the computer.

【0085】セル2100は、複数ワードで構成され、
1ワードのヘッダ部と、1ワードの作業用領域2106
と、可変長のデータ領域2107とからなる。ここで、
ヘッダ部は、有効セルフラグ領域2101とセル長領域
2102とリファレンスカウンタA領域2103とリフ
ァレンスカウンタB領域2104と作業フラグ領域21
05とから構成される。
The cell 2100 is composed of a plurality of words,
1-word header part and 1-word work area 2106
And a variable length data area 2107. here,
The header portion includes a valid cell flag area 2101, a cell length area 2102, a reference counter A area 2103, a reference counter B area 2104, and a work flag area 21.
And 05.

【0086】有効セルフラグ領域2101、リファレン
スカウンタA領域2103及びリファレンスカウンタB
領域2104はそれぞれ、実施の形態1で図2により示
した有効セルフラグ領域1101、リファレンスカウン
タA領域1103及びリファレンスカウンタB領域11
04と同等であり、そのためここでは説明を省略する。
Valid cell flag area 2101, reference counter A area 2103 and reference counter B
The areas 2104 are the valid cell flag area 1101, the reference counter A area 1103, and the reference counter B area 11 shown in FIG. 2 in the first embodiment, respectively.
Since it is equivalent to 04, the description is omitted here.

【0087】セル長領域2102は、実施の形態1で示
したセル長領域1102より1ビット大きく、ヘッダ部
と作業用領域とデータ領域とを合わせたセル長を示す値
を格納する22ビットの領域である。この領域に格納さ
れるセル長は、例えばワード数で表される。作業フラグ
領域2105は、実施の形態1で示した作業フラグ領域
1105より1ビット小さく、カウントアンドスイープ
処理においてセルに関する状態を示すために用いられる
作業フラグを格納する1ビットの領域である。作業フラ
グは0又は1の値をとり、カウントアンドスイープ処理
において最初は0にされる。
The cell length area 2102 is one bit larger than the cell length area 1102 described in the first embodiment, and is a 22-bit area for storing a value indicating the cell length of the header portion, the work area, and the data area. Is. The cell length stored in this area is represented by the number of words, for example. The work flag area 2105 is a 1-bit area smaller than the work flag area 1105 described in the first embodiment, and stores a work flag used to indicate a state regarding a cell in the count and sweep process. The work flag takes a value of 0 or 1, and is initially set to 0 in the count and sweep process.

【0088】作業用領域2106は、作業用先頭セルア
ドレスを格納するためにメモリ300内に予め設けられ
た1ワードの領域を始点として、各セルをポインタチェ
ーンで繋ぐために用いられる領域であり、カウントアン
ドスイープ処理においてルートポインタに端を発するポ
インタチェーンで繋がれているセルであると判定された
場合に、他のセルのアドレスが格納される。
The work area 2106 is an area used for connecting each cell with a pointer chain, starting from a 1-word area provided in advance in the memory 300 for storing the work start cell address. In the count and sweep processing, when it is determined that the cell is connected by the pointer chain originating from the root pointer, the address of another cell is stored.

【0089】なお、セル2100が、作業用先頭セルア
ドレスからのポインタチェーンで繋がれていない場合に
は、作業用領域2106にはNULLが格納されてお
り、そのポインタチェーンで繋がれている場合であって
チェーンの終端であれば、終端を示すために予め定めら
れている値、例えば、0xFFFFFFFF等(以下、
「終端マーク」という。)が格納されており、そのポイ
ンタチェーンで繋がれている場合であってチェーンの終
端でなければ、次のセルのアドレスが格納されている。
When the cell 2100 is not connected by the pointer chain from the work start cell address, NULL is stored in the work area 2106, and when it is connected by the pointer chain. If it is the end of the chain, a predetermined value for indicating the end, such as 0xFFFFFFFF (hereinafter,
It is called "end mark". ) Is stored and is connected by the pointer chain and is not the end of the chain, the address of the next cell is stored.

【0090】また、データ領域2107は、実施の形態
1で示したデータ領域1106と同等であり、そのため
ここでは説明を省略する。図15は、実施の形態2にお
けるセルの作業用先頭セルアドレス30からのポインタ
チェーンを例示する図である。同図においては、矢印の
先端により、アドレスが指すセルを示している。
Further, the data area 2107 is equivalent to the data area 1106 shown in the first embodiment, and therefore its explanation is omitted here. FIG. 15 is a diagram exemplifying a pointer chain from the working head cell address 30 of the cell in the second embodiment. In the figure, the tip of the arrow indicates the cell pointed to by the address.

【0091】作業用先頭セルアドレス30はセルa31
のアドレスであり、セルa31の作業用領域にはセルb
32のアドレスが格納されており、セルb32の作業用
領域にはセルc33のアドレスが格納されており、セル
c33の作業用領域には終端マークが格納されている。
また、ポインタチェーンから外れているセルd34の作
業用領域にはNULLが格納されている。
The working head cell address 30 is the cell a31.
Address of the cell a and the work area of the cell a31 is the cell b.
The address of 32 is stored, the work area of the cell b32 stores the address of the cell c33, and the end mark is stored in the work area of the cell c33.
Further, NULL is stored in the work area of the cell d34 which is out of the pointer chain.

【0092】この実施の形態2では、この作業用先頭セ
ルアドレス30に端を発するポインタチェーンに対し
て、カウントアンドスイープ処理においてセルを接続し
たり切り離したりする際に、ラストインファーストアウ
トのスタックアルゴリズムを用いる。このため、作業用
先頭セルアドレス30からのポインタチェーンで示され
るセルについては、作業用スタックにそのセルが格納さ
れていると表現する。また、セルを作業用スタックにP
USHするという表現により、ポインタチェーンの先頭
にセルを挿入することを表し、セルを作業用スタックか
らPOPするという表現により、ポインタチェーンの先
頭のセルをチェーンから取り除くことを表す。
In the second embodiment, the last-in first-out stack algorithm is used when connecting or disconnecting cells in the count-and-sweep process with respect to the pointer chain originating from the work start cell address 30. To use. Therefore, the cell indicated by the pointer chain starting from the work start cell address 30 is expressed as having the cell stored in the work stack. In addition, P the cell to the working stack
The expression USH means to insert a cell at the head of the pointer chain, and the expression POP the cell from the working stack means to remove the head cell of the pointer chain from the chain.

【0093】例えば、図15に示す状態において、セル
d34を作業用スタックにPUSHすると、作業用先頭
セルアドレスはセルd34のアドレスを指すように書き
かえられ、セルd34の作業用領域にはセルa31のア
ドレスが格納されることになる。また、その直後に、作
業用スタックからPOPできるセルはセルd34とな
り、セルd34をPOPするとポインタチェーンからセ
ルd34が除かれ、その状態は図15に示すものに戻
る。なお、POP時にはPOPしたセルの作業用領域に
はNULLが設定される。
For example, in the state shown in FIG. 15, when the cell d34 is pushed to the working stack, the working head cell address is rewritten so as to indicate the address of the cell d34, and the cell a31 is stored in the working area of the cell d34. Will be stored. Immediately after that, the cell that can be POP from the working stack becomes the cell d34, and when the cell d34 is POP, the cell d34 is removed from the pointer chain, and the state returns to that shown in FIG. At the time of POP, NULL is set in the work area of the POP cell.

【0094】<2-3.動作>以下、上述したセルを対象
としたガベージコレクションを行う変形ガベージコレク
ション装置と、これに関連し、アプリケーションプログ
ラムの解釈実行の制御を行う変形制御機構との動作につ
いて説明する。 <2-3-1.セルの生成>アプリケーションプログラムの
コードを逐次解釈し実行のための制御を行う変形制御機
構は、オブジェクト生成用のコードを解釈対象としたと
きに、セル確保部201によりセル生成処理を行う。
<2-3. Operation> Hereinafter, the operation of the modified garbage collection device that performs the garbage collection for the cells described above and the related deformation control mechanism that controls the interpretation and execution of the application program will be described. <2-3-1. Cell Generation> The transformation control mechanism that sequentially interprets the code of the application program and performs control for execution causes the cell securing unit 201 to perform cell generation processing when the code for object generation is an interpretation target.

【0095】図16は、変形制御機構におけるセル確保
部201が行うセル生成処理を示すフローチャートであ
る。セル確保部201は、セルに格納すべきオブジェク
トのデータの量と、ヘッダ部の1ワード分と作業用領域
の1ワード分とを合わせたサイズのセルを確保し、その
セルの有効セルフラグを1にし(ステップS611)、
そのサイズに基づいてセル長を設定する(ステップS6
12)。このセルの確保にあたり、セル確保部201
は、メモリ300中の有効セルフラグが0であるフリー
領域を探索して、そのフリー領域の全部又は一部を利用
して新たにセルとして利用する。
FIG. 16 is a flowchart showing a cell generation process performed by the cell securing unit 201 in the transformation control mechanism. The cell securing unit 201 secures a cell having a size including the amount of object data to be stored in the cell, one word of the header portion and one word of the work area, and sets the valid cell flag of the cell to 1 (Step S611),
The cell length is set based on the size (step S6).
12). In securing this cell, the cell securing unit 201
Searches for a free area in which the valid cell flag is 0 in the memory 300, and uses all or part of the free area as a new cell.

【0096】セル長を設定した後、セル確保部201
は、その確保したセルのリファレンスカウンタA及びB
を0とし、作業フラグを0にし、作業用領域にNULL
を設定する(ステップS613)。アプリケーションプ
ログラムにおけるオブジェクト生成用のコードにおい
て、通常は生成したオブジェクトを指すようにオブジェ
クトポインタへの代入が示されており、この場合におい
ては、ステップS613の後に、変形制御機構はポイン
タ設定部202によりポインタの変更を変形ガベージコ
レクション装置に伝えて、ポインタ変更対応処理を行わ
せることになる(ステップS614)。
After setting the cell length, the cell securing unit 201
Are the reference counters A and B of the secured cells.
Is set to 0, the work flag is set to 0, and the work area is set to NULL.
Is set (step S613). In the code for object generation in the application program, assignment to the object pointer is usually indicated so as to point to the generated object. In this case, after step S613, the transformation control mechanism causes the pointer setting unit 202 to set the pointer. Is transmitted to the modified garbage collection device, and pointer change handling processing is performed (step S614).

【0097】<2-3-2.ポインタの変更>変形ガベージ
コレクション装置の行うポインタ変更対応処理は、実施
の形態1で示したガベージコレクション装置100の行
うポインタ変更対応処理(図6参照)と基本的に同等で
ある。但し、実施の形態1において作業フラグが2であ
るか否かの判断をしている点(ステップS426)を、
実施の形態2では作業フラグが1であるか否かの判断を
するように置き換え、実施の形態1においてセル内の作
業フラグを1に変化させる点(ステップS428)を、
実施の形態2ではセルを作業用スタックにPUSHする
ように置き換える。なお、セル参照解除処理(図7参
照)についても同様に、実施の形態1において作業フラ
グが2であるか否かの判断をしている点(ステップS4
37)を、実施の形態2では作業フラグが1であるか否
かの判断をするように置き換える。
<2-3-2. Pointer Change> The pointer change handling process performed by the modified garbage collection device is basically the same as the pointer change handling process performed by the garbage collection device 100 described in the first embodiment (see FIG. 6). However, in the first embodiment, it is determined whether or not the work flag is 2 (step S426),
In the second embodiment, replacement is performed so as to determine whether or not the work flag is 1, and the point in which the work flag in the cell is changed to 1 in the first embodiment (step S428)
In the second embodiment, the cell is replaced with the working stack by PUSH. In the cell dereference process (see FIG. 7), it is similarly determined whether or not the work flag is 2 in the first embodiment (step S4).
37) is replaced so as to determine whether the work flag is 1 in the second embodiment.

【0098】<2-3-3.カウントアンドスイープ処理>
変形制御機構のカウントアンドスイープ指示部210
は、単位時間当たりにおいて、CPUがアプリケーショ
ンプログラムの実行に割り当てられる時間に対して比較
的少ない時間を用いて、メモリ300中において新たに
セルを割り当てることのできるメモリ領域が予め定めた
基準量より減少しているか否かの検出を行って、減少し
ている場合にはその比較的少ない時間を用いて変形ガベ
ージコレクション装置にカウントアンドスイープ処理を
行わせるよう制御する。
<2-3-3. Count and sweep processing>
Counting and sweeping instruction section 210 of deformation control mechanism
Is a relatively small amount of time per unit time for the CPU to execute the application program, and the memory area in the memory 300 where new cells can be allocated is reduced from a predetermined reference amount. Whether or not it is detected is detected, and when it is decreased, control is performed so that the modified garbage collection device is caused to perform the count-and-sweep process using the relatively short time.

【0099】図17は、変形ガベージコレクション装置
の行うカウントアンドスイープ処理を示すフローチャー
トである。変形制御機構のカウントアンドスイープ指示
部210からカウントアンドスイープ処理の実行が要求
されると、変形ガベージコレクション装置の再カウント
部140は、まず全てのセルについてのリファレンスカ
ウンタBを0にして作業フラグを0にし、作業用領域に
NULLを設定する(ステップS701)。なお、作業
用先頭セルアドレス30は、初期値が終端マークであ
り、このステップS701が実行される時点では終端マ
ークになっている。
FIG. 17 is a flowchart showing the count-and-sweep process performed by the modified garbage collection device. When the count-and-sweep instruction unit 210 of the transformation control mechanism requests execution of the count-and-sweep process, the re-counting unit 140 of the transformation garbage collection device first sets the reference counter B for all cells to 0 and sets the work flag. It is set to 0 and NULL is set in the work area (step S701). The initial value of the working head cell address 30 is an end mark, and is the end mark at the time when step S701 is executed.

【0100】ステップS701に続いて、再カウント部
140は、ルートポインタから直接指されている全ての
セルについて、リファレンスカウンタBを1増加して順
次、作業用スタックにPUSHする(ステップS70
2)。ここで、PUSHは、作業用先頭セルアドレス3
0のそのPUSH時点での値をそのPUSH対象となっ
たセルの作業用領域に格納するとともに、そのPUSH
対象となったセルのアドレスを作業用セルアドレス30
に設定することにより実現される。
Subsequent to step S701, the recount unit 140 increments the reference counter B by 1 for all cells directly pointed to by the root pointer and sequentially pushes them to the working stack (step S70).
2). Here, PUSH is the start cell address for work 3
The value of 0 at the time of the PUSH is stored in the work area of the PUSH target cell, and
The target cell address is the working cell address 30
It is realized by setting to.

【0101】ステップS702に続いて、再カウント部
140は、作業用スタックにセルが格納されているかを
判定する(ステップS703)。再カウント部140
は、作業用先頭セルアドレス30の値が終端マーク以外
であれば、作業用スタックにセルが格納されていると判
定し、終端マークであれば作業用スタックにセルが格納
されていないと判定する。
Subsequent to step S702, the recount unit 140 determines whether or not cells are stored in the working stack (step S703). Recount unit 140
If the value of the work head cell address 30 is other than the end mark, it is determined that the cell is stored in the work stack, and if it is the end mark, it is determined that the cell is not stored in the work stack. .

【0102】ステップS703において作業用スタック
にセルが格納されていると判定した場合には、再カウン
ト部140は作業用スタックから1つのセルをPOP
し、そのPOPしたセルの作業用フラグを1にし(ステ
ップS704)、そのセルの有効セルフラグを参照して
セルが有効であるか否かを判定する(ステップS70
5)。
When it is determined in step S703 that a cell is stored in the work stack, the recount unit 140 pops one cell from the work stack.
Then, the working flag of the POPed cell is set to 1 (step S704), and it is determined whether or not the cell is valid by referring to the valid cell flag of the cell (step S70).
5).

【0103】ここで、POPは、作業用先頭セルアドレ
ス30が指すセルのそのPOP時点での作業用領域の内
容を作業用先頭セルアドレス30に設定するとともに、
そのセルの作業用領域にNULLを格納することにより
実現される。ステップS705においてセルが有効であ
ると判定した場合には、再カウント部140は、そのセ
ル内の、セルを指すポインタ毎に、そのポインタが指す
セルのリファレンスカウンタBがMAX値でなければ1
増やすステップS707と、そのポインタが指すセルの
作業フラグが0であり、かつ、作業用領域がNULLで
あれば、そのポインタが指すセルを作業用スタックにP
USHするステップS708とを行う(ステップS70
6〜S708)。但し、ステップS704においてPO
Pしたセル内に、セルを指すポインタがない場合には、
ステップS707及びS708の処理は省略する。
Here, the POP sets the contents of the work area at the time of the POP of the cell pointed to by the work start cell address 30 in the work start cell address 30, and
It is realized by storing NULL in the work area of the cell. When it is determined in step S705 that the cell is valid, the recount unit 140 sets 1 for each pointer in the cell that points to the cell, unless the reference counter B of the cell pointed to by the pointer is the MAX value.
If the work flag of the cell pointed to by the pointer is 0 and the work area is NULL, the cell pointed to by the pointer is added to the work stack in step S707.
Perform USH step S708 (step S70
6-S708). However, in step S704, the PO
If there is no pointer to the cell in the P cell,
The processes of steps S707 and S708 are omitted.

【0104】ステップS706〜S708の後に、或い
はステップS705でセルが有効でないと判定した場合
に、再カウント部140は再び作業用スタックにセルが
格納されているかの判定に戻る(ステップS703)。
ステップS703において、作業用スタックにセルが格
納されていないと判定した場合には、再カウント部14
0は、全てのセルについてセル毎にステップS709〜
S712を行う(ステップS709)。
After steps S706 to S708, or when it is determined in step S705 that the cell is not valid, the recounting unit 140 returns to the determination whether the cell is stored in the working stack again (step S703).
In step S703, when it is determined that no cells are stored in the work stack, the recount unit 14
0 indicates step S709 for each cell for all cells.
S712 is performed (step S709).

【0105】即ち、再カウント部140は、全てのセル
それぞれについて順次、再カウント結果ゼロ判定部14
1により、セルのリファレンスカウンタBが0であるか
否かを判定し(ステップS710)、0でない場合に
は、カウンタ再設定部142がセルのリファレンスカウ
ンタAをリファレンスカウンタBと同じ値にするととも
に作業フラグを0にし(ステップS712)、0である
場合にはセル解放部130がそのセルの有効セルフラグ
を0にしてセルを解放する(ステップS711)。こう
して全てのセルについてステップS709以後の処理が
行われると、カウントアンドスイープ処理は完了する。
That is, the recounting unit 140 sequentially determines the recounting result zero determining unit 14 for each of all cells.
It is determined by 1 whether or not the reference counter B of the cell is 0 (step S710), and if it is not 0, the counter resetting unit 142 sets the reference counter A of the cell to the same value as the reference counter B, and The work flag is set to 0 (step S712), and when it is 0, the cell releasing unit 130 sets the valid cell flag of the cell to 0 and releases the cell (step S711). When the processing from step S709 is performed on all cells in this way, the count and sweep processing is completed.

【0106】なお、カウントアンドスイープ処理は、ア
プリケーションプログラムの実行と並行して行われる。
但し、カウントアンドスイープ処理は、図17に示す単
一ステップの実行中においてはアプリケーションプログ
ラムが実行されないようにし、さらにステップS704
の実行開始からステップS708の実行終了までの間に
おいてもアプリケーションプログラムが実行されないよ
うにされる必要がある。これは、例えば、マルチタスク
制御を行うOSに対して、変形ガベージコレクション装
置が単一ステップやステップS704〜S708の実行
中はCPUを専有することを宣言する等によって実現さ
れる。
The count and sweep process is performed in parallel with the execution of the application program.
However, in the count and sweep process, the application program is not executed during execution of the single step shown in FIG. 17, and further, step S704.
It is necessary to prevent the application program from being executed during the period from the start of execution of step 1 to the end of step S708. This is realized by, for example, declaring to the OS that performs multitask control that the modified garbage collection device occupies the CPU during a single step or during execution of steps S704 to S708.

【0107】以下、上述したカウントアンドスイープ処
理の進行を図18〜図22を用いて段階を追って説明す
る。図18は、カウントアンドスイープ処理におけるス
テップS701の終了直後のセルの内容とセル間の関係
を例示した図である。ここでは、説明を簡単にするため
に6つのセルのみを示している。
The progress of the above count and sweep processing will be described below step by step with reference to FIGS. FIG. 18 is a diagram exemplifying the content of cells and the relationship between cells immediately after the end of step S701 in the count and sweep process. Only six cells are shown here for ease of explanation.

【0108】カウントアンドスイープ処理の実行前にお
いては、セル41〜46はいずれも有効セルフラグは1
で有効を示しており、セル41、セル43、セル44及
びセル46のリファレンスカウンタAはMAX値になっ
ており、セル42及びセル45のリファレンスカウンタ
Aは1であるものとする。同図に示す状態は、カウント
アンドスイープ処理のステップS701により、まずセ
ル41〜46の全てについて、リファレンスカウンタB
が0にされるとともに作業フラグが0にされた時点の状
態である。この時点での作業用先頭セルアドレスの値は
終端マークである。
Before execution of the count and sweep processing, all the cells 41 to 46 have the valid cell flag set to 1.
Is valid, the reference counter A of the cell 41, the cell 43, the cell 44, and the cell 46 is the MAX value, and the reference counter A of the cell 42 and the cell 45 is 1. In the state shown in the figure, the reference counter B is first set for all the cells 41 to 46 by step S701 of the count and sweep process.
Is set to 0 and the work flag is set to 0. The value of the working top cell address at this point is the end mark.

【0109】図19は、カウントアンドスイープ処理に
おけるステップS702の実行の終了直後のセルの内容
とセル間の関係を例示した図である。同図に示す状態
は、図18に示す状態を前提として、ステップS702
によりルートポインタから指されているセル41につい
て、リファレンスカウンタBが1に増やされ、作業用ス
タックにPUSHされた時点の状態である。
FIG. 19 is a diagram exemplifying the contents of cells and the relationship between cells immediately after the execution of step S702 in the count and sweep process. The state shown in the figure is based on the state shown in FIG.
For the cell 41 pointed to by the root pointer by, the reference counter B is incremented to 1 and is pushed to the working stack.

【0110】図20は、カウントアンドスイープ処理に
おけるステップS706の繰り返し処理が終わった直後
のセルの内容とセル間の関係を例示した図である。同図
に示す状態は、図19に示す状態を前提として、ステッ
プS704によりセル41がPOPされかつその作業フ
ラグを1にされ、セル41が保持するポインタが指すセ
ル42及びセル45が順次作業用スタックにPUSHさ
れかつリファレンスカウンタBを1増やされた状態であ
る。
FIG. 20 is a diagram exemplifying the content of cells and the relationship between cells immediately after the repetition processing of step S706 in the count and sweep processing is completed. In the state shown in the figure, on the premise of the state shown in FIG. 19, the cell 41 is popped and the work flag is set to 1 in step S704, and the cells 42 and 45 pointed to by the pointer held by the cell 41 are sequentially used for work. In this state, the stack is PUSHed and the reference counter B is incremented by one.

【0111】図21は、カウントアンドスイープ処理に
おいて再びステップS706が終わった直後のセルの内
容とセル間の関係を例示した図である。同図に示す状態
は、図20に示す状態を前提として、ステップS704
によりセル45がPOPされかつその作業フラグを1に
され、セル45が保持するポインタが指すセル46が作
業用スタックにPUSHされかつリファレンスカウンタ
Bを1増やされた状態である。
FIG. 21 is a diagram exemplifying the content of cells and the relationship between cells immediately after step S706 is finished in the count and sweep processing. The state shown in the figure is based on the state shown in FIG.
The cell 45 is POPed and the work flag is set to 1, and the cell 46 pointed by the pointer held by the cell 45 is PUSHed to the work stack and the reference counter B is incremented by one.

【0112】図22は、カウントアンドスイープ処理に
おいてステップS703のnoの分岐に進んだ直後のセ
ルの内容とセル間の関係を例示した図である。同図に示
す状態は、図21に示す状態を前提として、ステップS
703〜S708の処理を繰り返し行うことにより、作
業用スタックに格納されているセルがなくなった時点の
状態である。この時、各セルはそのセルが参照されてい
る数をリファレンスカウンタBにより示すことになる。
FIG. 22 is a diagram exemplifying the contents of cells and the relationship between cells immediately after proceeding to the no branch of step S703 in the count and sweep process. The state shown in the figure is based on the state shown in FIG.
This is the state at the time when there are no cells stored in the working stack by repeating the processing of 703 to S708. At this time, each cell indicates the number of times the cell is referenced by the reference counter B.

【0113】この図22に示した状態の後、ステップS
709〜S712が行われることにより、セル44は有
効セルフラグが0にされることにより解放され、他のセ
ルではリファレンスカウンタAがリファレンスカウンタ
Bと同じ値に再設定されることになる。 <2-4.考察>このように各セルに作業用領域を設けて
作業用スタックを利用する方式によれば、実施の形態1
で示したような灰色のセルを探索する処理にかかる時間
を短縮でき、高速にカウントアンドスイープ処理を行う
ことができるようになる。
After the state shown in FIG. 22, step S
709 to S712 are performed, the cell 44 is released by setting the valid cell flag to 0, and the reference counter A is reset to the same value as the reference counter B in the other cells. <2-4. Consideration> According to the method in which the work area is provided in each cell and the work stack is used, the first embodiment is described.
It is possible to shorten the time required for the process of searching for the gray cell as shown in, and to perform the count and sweep process at high speed.

【0114】なお、従来のリファレンスカウント方式を
用いる場合においても、セルへのポインタのチェーンが
ループしている場合に不要なセルを解放できないという
問題を解決するためにマークアンドスイープ方式を併せ
て用いることもあり、アプリケーションプログラムの動
作に並行してこのマークアンドスイープ方式による処理
を行うためには作業用スタックを用いる実施形態が有効
となる。この作業用スタックの実現のために各セルに1
ワードの作業用領域を設けた形態をとって従来のリファ
レンスカウント方式とマークアンドスイープ方式とを併
用した場合と対比すると、実施の形態2で示した方式
は、セルの被参照数の初期段階でのピーク値と後の安定
状態における値との格差が大きいときには、リファレン
スカウントのために必要なセル内の領域をより小さいも
のにできる可能性をもつ方式であるといえる。 <3.実施の形態3>以下、本発明の実施の形態3に係
るガベージコレクション装置(以下、「第2変形ガベー
ジコレクション装置」という。)について説明する。
Even when the conventional reference count method is used, the mark-and-sweep method is also used in order to solve the problem that unnecessary cells cannot be released when the chain of pointers to cells loops. In some cases, in order to perform the mark-and-sweep method processing in parallel with the operation of the application program, the embodiment using the work stack is effective. 1 for each cell to realize this working stack
Compared with the case where the conventional reference count method and the mark-and-sweep method are used in combination with the mode in which the word work area is provided, the method shown in the second embodiment is effective at the initial stage of the number of referenced cells. It can be said that this method has a possibility that the area in the cell required for reference counting can be made smaller when the difference between the peak value of 1 and the value in the later stable state is large. <3. Third Preferred Embodiment> Hereinafter, a garbage collection device according to a third preferred embodiment of the present invention (hereinafter, referred to as “second modified garbage collection device”) will be described.

【0115】<3-1.構成>第2変形ガベージコレクシ
ョン装置は、実施の形態1において説明したガベージコ
レクション装置100と基本的な構成は同じであるが、
リファレンスカウンタAとBとの2つではなく、セル毎
に1つしかリファレンスカウンタを用いなくても、リフ
ァレンスカウント方式を基礎としてカウントアンドスイ
ープ処理を行うことができるようにしたものである。以
下、第2変形ガベージコレクション装置の機能構成要素
についてはガベージコレクション装置100の機能構成
要素と同じ符号を用いて説明する(図1参照)。また、
この第2変形ガベージコレクション装置に対応し、実施
の形態1に示した制御機構200に相当する制御機構を
第2変形制御機構といい、その機能構成要素については
制御機構200の機能構成要素と同じ符号を用いて説明
する。
<3-1. Configuration> The second modified garbage collection device has the same basic configuration as the garbage collection device 100 described in the first embodiment,
Even if only one reference counter is used for each cell instead of two reference counters A and B, the count and sweep processing can be performed based on the reference counting method. The functional components of the second modified garbage collection device will be described below using the same reference numerals as the functional components of the garbage collection device 100 (see FIG. 1). Also,
A control mechanism corresponding to this second modified garbage collection device and corresponding to the control mechanism 200 shown in the first embodiment is referred to as a second modified control mechanism, and its functional components are the same as those of the control mechanism 200. Description will be given using reference numerals.

【0116】<3-2.データ>以下、第2変形ガベージ
コレクション装置の処理対象となり、アプリケーション
プログラムにおけるオブジェクトのデータを格納するた
めに用いられるデータ単位であるセルについて説明す
る。図23は、第2変形ガベージコレクション装置が取
り扱うセルのデータ構造を示す図である。なお、同図に
おける1行は、計算機の基本語長となるワード単位に相
当する。
<3-2. Data> Hereinafter, a cell that is a data unit used as a processing target of the second modified garbage collection device and used to store data of an object in an application program will be described. FIG. 23 is a diagram showing a data structure of cells handled by the second modified garbage collection device. It should be noted that one line in the figure corresponds to a word unit that is the basic word length of the computer.

【0117】セル3100は、複数ワードで構成され、
1ワードのヘッダ部と、可変長のデータ領域3105と
からなる。ここで、ヘッダ部は、有効セルフラグ領域3
101とセル長領域3102とリファレンスカウンタ領
域3103と作業フラグ領域3104とから構成され
る。有効セルフラグ領域3101及び作業フラグ領域3
104はそれぞれ、実施の形態1で図2により示した有
効セルフラグ領域1101及び作業フラグ領域1105
と同等であり、そのためここでは説明を省略する。な
お、この実施の形態3においては、実施の形態1と同様
にセルの作業フラグが0であることをセルが白色である
と、作業フラグが1であることをセルが灰色であると、
作業フラグが2であることをセルが黒色であるとも表現
する。
The cell 3100 is composed of a plurality of words,
It consists of a 1-word header section and a variable-length data area 3105. Here, the header portion is a valid cell flag area 3
101, a cell length area 3102, a reference counter area 3103, and a work flag area 3104. Valid cell flag area 3101 and work flag area 3
104 are valid cell flag areas 1101 and work flag areas 1105 shown in FIG. 2 in the first embodiment, respectively.
Therefore, the description is omitted here. In the third embodiment, as in the first embodiment, the work flag of the cell is 0, the cell is white, the work flag is 1, and the cell is gray.
The fact that the work flag is 2 is also expressed as the cell being black.

【0118】セル長領域3102は、実施の形態1で示
したセル長領域1102より4ビット大きく、ヘッダ部
と作業用領域とデータ領域とを合わせたセル長を示す値
を格納する25ビットの領域である。この領域に格納さ
れるセル長は、例えばワード数で表される。リファレン
スカウンタ領域3103は、リファレンスカウンタを格
納する4ビットの領域である。リファレンスカウンタは
0から15までの数を表すことができるが、最大値であ
る15は、セルが参照されている数が15以上に1度な
ってしまったためにリファレンスカウンタがオーバフロ
ーしていることを示すものとして用いられる。
The cell length area 3102 is 4 bits larger than the cell length area 1102 described in the first embodiment, and is a 25-bit area for storing a value indicating the cell length of the header portion, the work area, and the data area. Is. The cell length stored in this area is represented by the number of words, for example. The reference counter area 3103 is a 4-bit area for storing a reference counter. The reference counter can represent a number from 0 to 15. However, the maximum value of 15 means that the reference counter overflows because the number of times the cell is referenced is once more than 15. Used as an indicator.

【0119】データ領域3105は、実施の形態1で示
したデータ領域1106と同等であり、そのためここで
は説明を省略する。また、第2変形ガベージコレクショ
ン装置では、カウントアンドスイープ処理の実行中か否
かを示すために、メモリ中の1ビットをカウントアンド
スイープ実行中フラグと定めて、実行中であればカウン
トアンドスイープ実行中フラグをオン(ON)にし、実
行中でなければオフ(OFF)にする。
The data area 3105 is equivalent to the data area 1106 shown in the first embodiment, and therefore its explanation is omitted here. Further, in the second modified garbage collection device, in order to indicate whether or not the count and sweep process is being executed, one bit in the memory is set as a count and sweep executing flag, and if it is being executed, the count and sweep executing process is executed. The middle flag is turned on, and if not being executed, it is turned off.

【0120】<3-3.動作>以下、上述したセルを対象
としたガベージコレクションを行う第2変形ガベージコ
レクション装置と、これに関連し、アプリケーションプ
ログラムの解釈実行の制御を行う第2変形制御機構との
動作について説明する。 <3-3-1.セルの生成>アプリケーションプログラムの
コードを逐次解釈し実行のための制御を行う第2変形制
御機構は、オブジェクト生成用のコードを解釈対象とし
たときに、セル確保部201によりセル生成処理を行
う。
<3-3. Operation> Hereinafter, an operation of the second modified garbage collection device that performs the above-described garbage collection on the cell and the related second modified control mechanism that controls the interpretation and execution of the application program will be described. <3-3-1. Cell Generation> The second modification control mechanism that sequentially interprets the code of the application program and performs control for execution causes the cell securing unit 201 to perform the cell generation process when the code for object generation is the interpretation target.

【0121】このセル生成処理は、実施の形態1で示し
たセル生成処理(図5参照)と基本的に同等である。但
し、ステップS413の「リファレンスカウンタA及び
Bを0」とするところを「リファレンスカウンタを0」
とするように読み替える必要がある。 <3-3-2.ポインタの変更>第2変形制御機構は、アプ
リケーションプログラムにおけるオブジェクトポインタ
への代入のコードを解釈対象としたときにポインタ設定
部202を通じてポインタの変更を第2変形ガベージコ
レクション装置に伝える。なお、ポインタ設定部202
は、ポインタの変更を伝える際に、変更前後のポインタ
の値をも伝える。
This cell generation process is basically the same as the cell generation process (see FIG. 5) shown in the first embodiment. However, the step of setting “reference counters A and B to 0” in step S413 is “reference counter to 0”.
Should be read as <3-3-2. Pointer change> The second modification control mechanism notifies the second modification garbage collection device of the pointer modification through the pointer setting unit 202 when the code of assignment to the object pointer in the application program is to be interpreted. The pointer setting unit 202
When transmitting a pointer change, will also tell the pointer value before and after the change.

【0122】第2変形ガベージコレクション装置は、ポ
インタの変更が伝えられるとポインタ変更対応処理を行
う。図24は、第2変形ガベージコレクション装置の行
うポインタ変更対応処理を示すフローチャートである。
ポインタの変更が伝えられると、第2変形ガベージコレ
クション装置のカウンタ変更部110は、変更前のポイ
ンタがセルを指すか否かを判定し(ステップS82
1)、セルを指すものである場合には、その着目してい
る変更前のポインタに基づいてセル参照解除処理を行い
(ステップS822)、セルを指すものでない場合には
ステップS822のセル参照解除処理は行わない。つま
り変更前のポインタがNULLであればセル参照解除処
理は行わない。なお、セル参照解除処理については後に
図25を用いて説明する。
The second modified garbage collection device performs pointer change handling processing when the pointer change is notified. FIG. 24 is a flowchart showing pointer change handling processing performed by the second modified garbage collection device.
When the change of the pointer is transmitted, the counter changing unit 110 of the second modified garbage collection device determines whether or not the pointer before the change points to the cell (step S82).
1) If it points to a cell, cell reference cancellation processing is performed based on the focused pointer before change (step S822). If it does not point to a cell, cell reference cancellation in step S822. No processing is done. That is, if the pointer before the change is NULL, the cell reference cancellation processing is not performed. The cell reference cancellation processing will be described later with reference to FIG.

【0123】続いて、カウンタ変更部110は、変更後
のポインタがセルを指すか否かを判定し(ステップS8
23)、セルを指すものでない場合にはポインタ変更対
応処理を終了する。また、ステップS823において、
変更後のポインタがセルを指すものである場合には、カ
ウンタ変更部110は、カウントアンドスイープ実行中
フラグを参照してカウントアンドスイープ処理が実行中
であるか否かを判定し(ステップS824)、実行中で
あれば変更後のポインタを保持するセルは黒色であるか
否か、つまりそのセルの作業フラグは2であるか否かを
判定する(ステップS827)。
Then, the counter changing unit 110 determines whether or not the changed pointer points to the cell (step S8).
23) If the pointer does not point to a cell, the pointer change handling process ends. Also, in step S823,
If the changed pointer points to a cell, the counter changing unit 110 refers to the count-and-sweep executing flag to determine whether the count-and-sweep process is being executed (step S824). If it is being executed, it is determined whether or not the cell holding the changed pointer is black, that is, the work flag of the cell is 2 (step S827).

【0124】ステップS827において、変更後のポイ
ンタを保持するセルが黒色でないと判定した場合には、
カウンタ変更部110はポインタ変更対応処理を終了す
る。ステップS827において、変更後のポインタを保
持するセルが黒色であると判定した場合には、カウンタ
変更部110は、その変更後のポインタが指すセルの作
業フラグは0であるか否か、即ちそのセルが白色である
か否かを判定し(ステップS828)、白色である場合
に限りその変更後のポインタが指すセルの作業フラグを
0から1に変更する(ステップS829)。
If it is determined in step S827 that the cell holding the changed pointer is not black,
The counter change unit 110 ends the pointer change handling process. When it is determined in step S827 that the cell holding the changed pointer is black, the counter changing unit 110 determines whether the work flag of the cell pointed to by the changed pointer is 0, that is, It is determined whether or not the cell is white (step S828), and only when the cell is white, the work flag of the cell pointed by the changed pointer is changed from 0 to 1 (step S829).

【0125】ステップS828、S829の後には、或
いはステップS824においてカウントアンドスイープ
処理が実行中でないと判定した場合には、カウンタ変更
部110は、カウンタ最大値判定部111により、変更
後のポインタの指すセルのリファレンスカウンタがMA
X値であるか否かを判定し(ステップS825)、MA
X値でない場合にはカウンタ増加部112によりそのリ
ファレンスカウンタを1増やして(ステップS82
6)、ポインタ変更対応処理を終了し、MAX値である
場合にはステップS826を行わずにポインタ変更対応
処理を終了する。
After steps S828 and S829, or when it is determined in step S824 that the count-and-sweep process is not being executed, the counter changing unit 110 causes the counter maximum value determining unit 111 to point to the pointer after the change. The cell reference counter is MA
It is determined whether it is the X value (step S825), and MA
If it is not the X value, the counter increment unit 112 increments the reference counter by 1 (step S82).
6) The pointer change handling process ends, and if it is the MAX value, the pointer change handling process ends without performing step S826.

【0126】図25は、第2変形ガベージコレクション
装置の行うセル参照解除処理を示すフローチャートであ
る。なお、同図ではステップS836においてセル参照
解除処理を再帰的に実行するように表現している。ま
ず、カウンタ変更部110は、カウントアンドスイープ
実行中フラグを参照してカウントアンドスイープ処理が
実行中であるか否かを判定し(ステップS831)、実
行中でなければ、セル参照解除処理を行う直前に着目し
ていたポインタに基づき、カウンタ最大値判定部111
により、その着目していたポインタの指すセルのリファ
レンスカウンタはMAX値であるか否かを判定する(ス
テップS832)。
FIG. 25 is a flow chart showing the cell reference cancellation processing performed by the second modified garbage collection device. In the figure, in step S836, the cell reference canceling process is expressed recursively. First, the counter changing unit 110 refers to the count-and-sweep execution flag to determine whether the count-and-sweep processing is being executed (step S831), and if it is not being executed, performs the cell reference cancellation processing. Based on the pointer that was focused on immediately before, the counter maximum value determination unit 111
Thus, it is determined whether or not the reference counter of the cell pointed by the focused pointer is the MAX value (step S832).

【0127】以下、セル参照解除処理のステップS83
1を行う時点で着目していたポインタを処理対象ポイン
タということとする。ステップS832において、処理
対象ポインタの指すセルのリファレンスカウンタがMA
X値でないと判定した場合には、カウンタ変更部110
は、カウンタ減少部113によりそのリファレンスカウ
ンタを1減らし(ステップS833)、続いてカウンタ
ゼロ判定部120は、そのリファレンスカウンタが0に
なったか否かを判定する(ステップS834)。
In the following, step S83 of the cell reference cancellation processing.
The pointer that is focused on when 1 is performed is referred to as a processing target pointer. In step S832, the reference counter of the cell pointed to by the process pointer is MA
When it is determined that the value is not the X value, the counter changing unit 110
The counter decrement unit 113 decrements the reference counter by 1 (step S833), and then the counter zero determination unit 120 determines whether the reference counter has become 0 (step S834).

【0128】ステップS834において、リファレンス
カウンタが0になっていると判定された場合には、処理
対象ポインタの指すセルの保持する、セルへのポインタ
に順次着目してセル参照解除処理(図25)を繰り返す
(ステップS835、S836)。これにより、処理対
象ポインタの指すセルが保持する、セルへのポインタの
数だけステップS836が繰り返されることになる。な
お、処理対象ポインタの指すセルが、セルへのポインタ
を保持しない場合にはステップS836の処理は省略さ
れる。
If it is determined in step S834 that the reference counter is 0, the cell reference cancellation processing is performed by sequentially focusing on the pointers to the cells held by the cells pointed to by the processing target pointer (FIG. 25). Is repeated (steps S835 and S836). As a result, step S836 is repeated by the number of pointers to the cell held by the cell pointed to by the processing target pointer. If the cell pointed to by the processing target pointer does not hold the pointer to the cell, the process of step S836 is omitted.

【0129】セル解放部130は、ステップS834に
おいてリファレンスカウンタが0になっていると判定さ
れたセルについて、ステップS836の繰り返しの後
に、有効セルフラグを0にすることによりセルを解放し
(ステップS837)、これによりセル参照解除処理は
終了する。また、ステップS831においてカウントア
ンドスイープ処理が実行中であると判定した場合には、
カウンタ変更部110は、処理対象ポインタを保持する
セルが黒色であるか否かを判定し(ステップS83
8)、黒色であった場合には、カウンタ最大値判定部1
11により処理対象ポインタの指すセルのリファレンス
カウンタはMAX値であるか否かを判定する(ステップ
S839)。
The cell releasing unit 130 releases the cell by resetting the valid cell flag to 0 after repeating step S836 for the cell for which the reference counter is determined to be 0 in step S834 (step S837). Thus, the cell reference cancellation processing ends. If it is determined in step S831 that the count and sweep process is being executed,
The counter changing unit 110 determines whether the cell holding the processing target pointer is black (step S83).
8) If it is black, the counter maximum value determination unit 1
According to 11, it is determined whether or not the reference counter of the cell pointed to by the processing target pointer is the MAX value (step S839).

【0130】ステップS839において、カウンタ最大
値判定部111が処理対象ポインタの指すセルのリファ
レンスカウンタがMAX値でないと判定した場合には、
カウンタ減少部113はそのリファレンスカウンタを1
減らし(ステップS840)、これによりセル参照解除
処理は終了する。また、ステップS832において処理
対象ポインタの指すセルのリファレンスカウンタがMA
X値であると判定された場合と、ステップS834にお
いてリファレンスカウンタが0になっていないと判定さ
れた場合と、ステップS838において処理対象ポイン
タを保持するセルが黒色でないと判定された場合と、ス
テップS839において処理対象ポインタの指すセルの
リファレンスカウンタはMAX値であると判定された場
合とには、セル参照解除処理は終了する。
In step S839, if the counter maximum value determination unit 111 determines that the reference counter of the cell pointed to by the processing target pointer is not the MAX value,
The counter decrement unit 113 sets the reference counter to 1
Decrease (step S840), and the cell reference cancellation processing is thereby completed. Further, in step S832, the reference counter of the cell pointed to by the processing target pointer is MA.
If it is determined to be the X value, it is determined in step S834 that the reference counter is not 0, and it is determined in step S838 that the cell holding the processing target pointer is not black, When it is determined in S839 that the reference counter of the cell pointed to by the processing target pointer is the MAX value, the cell reference cancellation processing ends.

【0131】<3-3-3.カウントアンドスイープ処理>
第2変形制御機構のカウントアンドスイープ指示部21
0は、単位時間当たりにおいて、CPUがアプリケーシ
ョンプログラムの実行に割り当てられる時間に対して比
較的少ない時間を用いて、メモリ300中において新た
にセルを割り当てることのできるメモリ領域が予め定め
た基準量より減少しているか否かの検出を行って、減少
している場合にはその比較的少ない時間を用いて第2変
形ガベージコレクション装置にカウントアンドスイープ
処理を行わせるよう制御する。
<3-3-3. Count and sweep processing>
Count and sweep instruction unit 21 of the second deformation control mechanism
0 means that a memory area in which a cell can be newly allocated in the memory 300 is smaller than a predetermined reference amount by using a relatively short time per unit time for the CPU to execute the application program. Whether or not it is decreasing is detected, and if it is decreasing, the second modified garbage collection device is controlled to perform the count-and-sweep process using the relatively short time.

【0132】図26は、第2変形ガベージコレクション
装置の行うカウントアンドスイープ処理を示すフローチ
ャートである。カウントアンドスイープ指示部210か
らカウントアンドスイープ処理の実行が要求されると、
第2変形ガベージコレクション装置の再カウント部14
0は、まず、カウントアンドスイープ実行中フラグをO
Nにし(ステップS851)、全てのセルについてのリ
ファレンスカウンタを0にして作業フラグを0にする
(ステップS852)。これにより全てのセルが白色に
なる。
FIG. 26 is a flow chart showing the count and sweep process performed by the second modified garbage collection device. When the count-and-sweep instruction unit 210 requests execution of the count-and-sweep process,
Re-counting unit 14 of second modified garbage collection device
For 0, first set the count and sweep execution flag to O.
N (step S851), the reference counters for all cells are set to 0, and the work flags are set to 0 (step S852). This makes all cells white.

【0133】ステップS852に続いて、再カウント部
140は、ルートポインタから直接指されている全ての
セルについて、作業フラグを1にしてセルを灰色にする
とともに、リファレンスカウンタがMAX値でなければ
リファレンスカウンタを1増やす(ステップS85
3)。ステップS853に続いて、再カウント部140
は、ルートポインタに端を発するポインタチェーンを辿
って、灰色のセルを探索する(ステップS854)。
Subsequent to step S852, the recounting unit 140 sets the work flag to 1 to make the cells gray for all the cells directly pointed to by the root pointer, and sets the reference counter if it is not the MAX value. Increment the counter by 1 (step S85
3). Following step S853, the recount unit 140
Searches for a gray cell by following a pointer chain originating from the root pointer (step S854).

【0134】再カウント部140はステップS854の
探索の結果として、灰色のセルを探索できた場合には
(ステップS855)、探したその灰色のセル内におけ
るポインタであってセルを指すもの毎に、そのポインタ
が指すセルが白色ならば、そのセルの作業フラグを0か
ら1に変更することによってその白色のセルを灰色にす
るステップS857と、そのポインタが指すセルのリフ
ァレンスカウンタがMAX値でなければリファレンスカ
ウンタを1増やすステップS858とを繰り返し行う
(ステップS856〜S858)。但し、探した灰色の
セル内にセルを指すポインタがない場合にはステップS
857及びS858の処理は省略する。
As a result of the search in step S854, the recount unit 140 finds a gray cell (step S855), and for each pointer in the gray cell found that points to the cell, If the cell pointed to by the pointer is white, step S857 of making the white cell gray by changing the work flag of the cell from 0 to 1, and if the reference counter of the cell pointed to by the pointer is not the MAX value The step S858 of incrementing the reference counter by 1 is repeated (steps S856 to S858). However, if there is no pointer that points to the cell in the gray cell that was searched for, step S
The processes of 857 and S858 are omitted.

【0135】探したその灰色のセル内のポインタ毎にス
テップS856により、ステップS857及びS858
を繰り返し行った後に、再カウント部140は、その灰
色のセルを黒色にし(ステップS859)、ステップS
854の処理に戻る。即ち、また別の灰色のセルの探索
を開始する。こうしてステップS854〜S859が繰
り返され、灰色のセルが存在しなくなった場合には、再
カウント部140は、ステップS855においてnoの
分岐に進み、全てのセルについてセル毎にステップS8
60〜S862を行う(ステップS860)。即ち、再
カウント部140は、全てのセルそれぞれについて順
次、再カウント結果ゼロ判定部141により、セルのリ
ファレンスカウンタが0であるか否かを判定し(ステッ
プS861)、0である場合に限りセル解放部130が
そのセルの有効セルフラグを0にしてセルを解放する
(ステップS862)。こうして全てのセルについてス
テップS860による処理の繰り返しを行った後に、第
2変形ガベージコレクション装置はカウントアンドスイ
ープ実行中フラグをOFFにし(ステップS863)、
カウントアンドスイープ処理を終了する。
For each pointer in the searched gray cell, steps S857 and S858 are performed by step S856.
After repeating, the recount unit 140 turns the gray cell into black (step S859),
Returning to the processing of 854. That is, the search for another gray cell is started. In this way, steps S854 to S859 are repeated, and when the gray cell does not exist, the recount unit 140 proceeds to no branch in step S855, and step S8 for each cell for all cells.
60 to S862 are performed (step S860). That is, the recount unit 140 sequentially determines whether the reference counter of the cell is 0 by the recount result zero determination unit 141 for each of all cells (step S861), and only when it is 0, the cell The releasing unit 130 sets the valid cell flag of the cell to 0 and releases the cell (step S862). After repeating the process in step S860 for all cells in this way, the second modified garbage collection device turns off the count-and-sweep execution flag (step S863),
Ends the count and sweep process.

【0136】なお、カウントアンドスイープ処理は、ア
プリケーションプログラムの実行と並行して行われる。
但し、カウントアンドスイープ処理は、図26に示す単
一ステップの実行中においてはアプリケーションプログ
ラムが実行されないようにし、さらにステップS856
の実行開始からステップS859の実行終了までの間に
おいてもアプリケーションプログラムが実行されないよ
うにされる必要がある。これは、例えば、マルチタスク
制御を行うOSに対して、第2変形ガベージコレクショ
ン装置が単一ステップやステップS856〜S859の
実行中はCPUを専有することを宣言する等によって実
現される。
The count and sweep processing is performed in parallel with the execution of the application program.
However, in the count and sweep process, the application program is not executed during execution of the single step shown in FIG. 26, and further, step S856.
It is necessary to prevent the application program from being executed during the period from the start of execution to the end of execution of step S859. This is realized by, for example, declaring to the OS that performs multitask control that the second modified garbage collection device occupies the CPU during a single step or during execution of steps S856 to S859.

【0137】<3-4.考察>このようにセル毎にリファ
レンスカウンタを1つだけ用いることとする方式によれ
ば、カウントアンドスイープ処理の実行中においては、
ポインタの変更によってどこからも参照されなくなった
セルを即座に解放することはできなくなるが、リファレ
ンスカウンタを2つ用いる方式よりもリファレンスカウ
ントのために必要な領域が少ないので、セル長領域に多
くのビットを割り当てることや、1ワードのヘッダ部に
他の情報を盛り込むこと等が可能になる。 <4.補足>以上、本発明に係るガベージコレクション
装置について、実施の形態1〜3を用いて説明したが、
本発明はこのような実施の形態に限られないことは勿論
である。即ち、 (1)実施の形態1〜3では、ガベージコレクションを
ガベージコレクション装置と制御機構との連携により行
うこととしたが、これらはソフトウェアで実現されるも
のであるため、両者を明確に分離する必要性はなく、ま
た、相互の機能分担を変更しても差し支えなく、ガベー
ジコレクション装置に制御機構の一部機能を含めてもよ
い。 (2)実施の形態1〜3では、リファレンスカウンタが
0〜15の数を表せる4ビットで構成され、0から14
までの被参照数をカウントでき、15という値でカウン
タのオーバフローを表すこととしたが、リファレンスカ
ウンタのサイズはこれに限定されることはない。基本的
に、セルの生成からある程度時間が経過したときにおけ
るセルの被参照数、言い換えればピーク時ではなく定常
状態における安定値(図29参照)を、オーバフローす
ることなくカウント可能な程度であってピーク値はカウ
ント不可能な程度の小さ目なサイズにするのが適切であ
る。なお、安定値はアプリケーションプログラムの構造
に依存する面をもつため、実行対象のアプリケーション
プログラムを想定して、リファレンスカウンタを適切に
定めるとよい。例えば、安定値が20程度であれば、リ
ファレンスカウンタとしては0〜31の数を表せる5ビ
ット程度が適切なものとなる。 (3)実施の形態1〜3で示した各セル中のセル長領域
のサイズは、単なる一例にすぎず、例えばセル長領域の
サイズを小さくしてその分だけ他の管理用の情報等をセ
ル内に盛り込んでもよい。 (4)実施の形態1〜3では、メモリ不足を検出したと
きにカウントアンドスイープ処理を実行することとした
が、これに限定されることはなく、単に周期的にカウン
トアンドスイープ処理を実行することとしてもよい。ま
た、例えばリファレンスカウンタがMAX値になってい
るセルの数を把握しておき、その数が所定の基準値より
多くなった場合にカウントアンドスイープ処理を実行す
ることとしてもよい。
<3-4. Consideration> According to the method in which only one reference counter is used for each cell as described above, during the execution of the count and sweep process,
Although it is not possible to immediately release cells that are no longer referenced by changing the pointer, the area required for reference counting is smaller than the method that uses two reference counters, so there are many bits in the cell length area. Can be assigned, and other information can be included in the header portion of one word. <4. Supplement> The garbage collection device according to the present invention has been described above using the first to third embodiments.
Of course, the present invention is not limited to such an embodiment. That is, (1) In the first to third embodiments, the garbage collection is performed by the cooperation of the garbage collection device and the control mechanism, but since these are realized by software, they are clearly separated. There is no need, the mutual function sharing may be changed, and the garbage collection device may include some functions of the control mechanism. (2) In the first to third embodiments, the reference counter is composed of 4 bits that can represent a number of 0 to 15,
Although the number of referents up to is counted, and the value of 15 represents the overflow of the counter, the size of the reference counter is not limited to this. Basically, it is possible to count the number of cells to be referred to when a certain amount of time has passed since the generation of cells, in other words, a stable value (see FIG. 29) in a steady state rather than at peak time, without overflow. It is appropriate to set the peak value to a small size that cannot be counted. Since the stable value has a surface depending on the structure of the application program, the reference counter may be appropriately determined by assuming the application program to be executed. For example, when the stable value is about 20, a suitable reference counter is about 5 bits that can represent a number of 0 to 31. (3) The size of the cell length area in each cell shown in the first to third embodiments is merely an example. For example, the size of the cell length area is reduced and other management information or the like is added. It may be included in the cell. (4) In the first to third embodiments, the count and sweep process is executed when the memory shortage is detected. However, the present invention is not limited to this, and the count and sweep process is simply executed periodically. It may be that. Alternatively, for example, the number of cells in which the reference counter has the MAX value may be grasped, and the count and sweep process may be executed when the number becomes larger than a predetermined reference value.

【0138】また、カウントアンドスイープ処理はアプ
リケーションプログラムとは別のスレッドとして、アプ
リケーションプログラムに対して少ない時間配分で動作
するように制御する方法の他に、アプリケーションプロ
グラムが実行されないようにして、即ちアプリケーショ
ンプログラムの実行を一時的に中断して、カウントアン
ドスイープ処理を最初から最後まで行うという方法を用
いてもよい。 (5)実施の形態1〜3では、セルのデータ領域にデー
タ型の情報とデータを格納することとしたが、これに限
定されることはなく、データ領域の内容は、そのデータ
領域に格納されているデータがセルへのポインタである
か否かの判断ができるようなものであれば足りる。例え
ば、データ領域にはデータ型を含ませず単にデータのみ
を格納することとして、そのデータの値を、予め定めた
セルの所在するアドレス範囲に関するルール等に基づい
て解析することにより、そのデータがセルへのポインタ
か否かを判断するようにしてもよい。 (6)実施の形態1における図8のステップS512、
及び実施の形態2における図17のステップS712で
は、リファレンスカウンタBをリファレンスカウンタA
にコピーすることとしたが、必ずしも全てコピー必要は
なく、リファレンスカウンタAがMAX値になっている
場合にのみそのリファレンスカウンタAを、リファレン
スカウンタBの値と同じ値にすることとしてもよい。 (7)実施の形態2では、作業用スタックを、セル内に
作業用領域を設けてポインタチェーンを張ることにより
実現したが、セルに使用するのとは別のメモリ領域に連
続したスタック領域を設けて、セルへのポインタを積ん
だり取り出したり、つまりPUSHしたりPOPしたり
するようにしてもよい。 (8)実施の形態1及び2で示したガベージコレクショ
ン装置におけるカウントアンドスイープ処理は、セルが
確保されて初めて参照されてから、どこからも参照され
なくなるまでの平均的な期間として設計上予測される期
間より短い周期で、繰り返し実行を開始されるようにガ
ベージコレクション装置を構築してもよい。このように
することで、平均的な生存期間を有するセルについて
は、セルが確保された後に一旦リファレンスカウンタが
オーバフローしても、セルが不要になるまでの間に、カ
ウントアンドスイープ処理により再度リファレンスカウ
ンタが有効値に戻ることとなり、カウントアンドスイー
プ処理が特に効果的に機能するようになる。なお、セル
が確保された初めて参照されてから、どこからも参照さ
れなくなるまでの期間については、アプリケーションプ
ログラムの実行中にガベージコレクション装置の内部又
は外部の機構により、測定し算定して、この算定した期
間に応じてガベージコレクション装置は、カウントアン
ドスイープ処理の実行開始タイミングを決定することと
してもよい。 (9)実施の形態1〜3で示したルートポインタは、変
更されないことを想定しているが、変更可能とするため
には、例えば、ルートポインタを保持する領域を1つの
セルとして構成し、カウントアンドスイープ開始の際に
は、このセルの作業フラグを黒色に設定する方式か、又
は、実施の形態1等で示したポインタ変更処理中で、変
更後のルートポインタが指し示すセルが白色であった場
合にはそのセルを灰色に変更するような処理を行う方式
を採用するとよい。 (10)実施の形態1〜3で示したガベージコレクショ
ン装置及び制御機構の処理手順、(図5〜8、図16、
図17、図24〜26に示した手順等)を、コンピュー
タ又は情報家電機器に実行させるためのコンピュータプ
ログラムを、記録媒体に記録し又は各種通信路等を介し
て、流通させ頒布することもできる。このような記録媒
体には、ICカード、光ディスク、フレキシブルディス
ク、ROM等がある。流通、頒布されたコンピュータプ
ログラムは、コンピュータ又は情報家電機器にインスト
ール等されることにより利用に供され、そのコンピュー
タ又は情報家電機器は当該コンピュータプログラムを実
行して、実施の形態1〜3で示したようなガベージコレ
クションを行うことができるようになる。
The count-and-sweep process is a thread separate from the application program and is controlled so that the application program operates with a small time allocation. A method of temporarily interrupting the execution of the program and performing the count and sweep processing from the beginning to the end may be used. (5) In the first to third embodiments, the data type information and the data are stored in the cell data area, but the present invention is not limited to this, and the contents of the data area are stored in the data area. It is sufficient if it is possible to determine whether the stored data is a pointer to a cell. For example, by storing only data without including the data type in the data area, and analyzing the value of the data based on a predetermined rule regarding the address range where the cell is located, the data is You may make it determine whether it is a pointer to a cell. (6) Step S512 of FIG. 8 in the first embodiment,
In step S712 of FIG. 17 in the second embodiment, the reference counter B is set to the reference counter A.
However, the reference counter A may be set to the same value as the value of the reference counter B only when the reference counter A has the MAX value. (7) In the second embodiment, the work stack is realized by providing a work area in a cell and extending a pointer chain. However, a continuous stack area is provided in a memory area different from that used for the cell. Alternatively, the pointers to the cells may be loaded or unloaded, that is, PUSH or POP may be performed. (8) The count-and-sweep process in the garbage collection device shown in the first and second embodiments is predicted by design as an average period from the time when the cell is first reserved and the time when the cell is no longer referenced. The garbage collection device may be constructed so that the repetitive execution is started in a cycle shorter than the period. By doing this, for cells with an average lifetime, even if the reference counter overflows after the cells are secured, the reference is re-referenced by the count-and-sweep process until the cells are no longer needed. The counter returns to a valid value, and the count-and-sweep process works particularly effectively. The period from when the cell is first referenced to when it is no longer referenced is measured and calculated by the internal or external mechanism of the garbage collection device during execution of the application program. The garbage collection device may determine the execution start timing of the count and sweep process depending on the period. (9) Although it is assumed that the route pointers shown in the first to third embodiments are not changed, in order to make them changeable, for example, the region holding the route pointer is configured as one cell, At the start of counting and sweeping, the work flag of this cell is set to black, or the cell pointed to by the changed root pointer is white during the pointer changing process described in the first embodiment or the like. In that case, it is advisable to adopt a method of performing a process of changing the cell to gray. (10) Processing procedure of the garbage collection device and the control mechanism shown in the first to third embodiments (see FIGS.
It is also possible to record a computer program for causing a computer or information home appliance to execute the procedures shown in FIGS. 17 and 24 to 26) in a recording medium or to distribute and distribute the program through various communication paths. . Such recording media include IC cards, optical disks, flexible disks, ROMs and the like. The distributed or distributed computer program is provided for use by being installed in a computer or an information home electric appliance, and the computer or the information home electric appliance executes the computer program, and is shown in the first to third embodiments. You will be able to perform such garbage collection.

【0139】[0139]

【発明の効果】<5.実施の形態1に係るガベージコレ
クション装置の効果の検証>以下、実施の形態1で示し
たカウントアンドスイープ処理によるガベージコレクシ
ョン(以下、「新ガベージコレクション」という。)の
効果を検証すべく行ったシミュレーション実験の内容及
び結果について簡単に説明する。
Effect of the Invention <5. Verification of Effect of Garbage Collection Device According to First Embodiment> Hereinafter, a simulation performed to verify the effect of garbage collection (hereinafter referred to as “new garbage collection”) by the count-and-sweep process described in the first embodiment. The contents and results of the experiment will be briefly described.

【0140】このシミュレーション実験は、新ガベージ
コレクションと、上述した従来のカウンタ制限リファレ
ンスカウント方式を一部変形した方式によるガベージコ
レクション(以下、「旧ガベージコレクション」とい
う。)とを対比して行った。ここで、旧ガベージコレク
ションは、カウンタ制限リファレンスカウント方式か
ら、リファレンスカウンタがオーバフローした場合にお
ける処理、つまりそのセルを特定領域にコピーする等の
処理を省き、オーバフローしたリファレンスカウンタに
ついてはカウントアップ及びカウントダウンの対象から
外すこととし、更にマークアンドスイープ方式によるガ
ベージコレクション処理を追加したものである。
This simulation experiment was carried out by comparing the new garbage collection with the garbage collection (hereinafter referred to as "old garbage collection") by a method that is a partial modification of the conventional counter-limited reference counting method described above. Here, the old garbage collection omits the processing when the reference counter overflows, that is, the processing such as copying the cell to a specific area, from the counter-limited reference counting method, and counts up and down the overflowed reference counter. It is excluded from the target, and the garbage collection processing by the mark-and-sweep method is added.

【0141】<5-1.実験内容>アプリケーションプロ
グラムが一定時間毎に単一サイズのオブジェクト(セ
ル)を生成する状況下で、オブジェクトにより占有され
たメモリ量が一定量になる毎にマークアンドスイープ処
理或いはカウントアンドスイープ処理によるガベージコ
レクションを実行し、そのガベージコレクションの実行
頻度等を調べたものである。
<5-1. Experiment contents> Under the situation that the application program creates a single size object (cell) at regular time intervals, garbage is generated by mark-and-sweep processing or count-and-sweep processing each time the amount of memory occupied by the object becomes constant. The collection is executed and the frequency of garbage collection is checked.

【0142】ここで、時間の単位としてステップを用
い、アプリケーションプログラムは100ステップ間に
おいて10オブジェクトを生成するものとする。また、
1つのオブジェクトの生存期間における被参照数は、図
30に示すように時間経過とともに変化するものとす
る。また、全メモリ量は、オブジェクト300個分のサ
イズとし、ガベージコレクションの実行タイミングは、
オブジェクトにより占有されたメモリ量が全メモリ量の
9割に達した時であることとする。
Here, it is assumed that steps are used as a unit of time and the application program generates 10 objects in 100 steps. Also,
It is assumed that the number of referenced objects in the lifetime of one object changes with time as shown in FIG. In addition, the total amount of memory is the size of 300 objects, and the execution timing of garbage collection is
It is assumed that the memory amount occupied by the object reaches 90% of the total memory amount.

【0143】また、旧ガベージコレクションにおけるセ
ルのヘッダ部は有効セルフラグ領域(1ビット)、セル
長領域(25ビット)、リファレンスカウンタ領域(4
ビット)及び作業フラグ(2ビット)の計32ビットで
構成され、新ガベージコレクションにおけるセルのヘッ
ダ部は有効セルフラグ領域(1ビット)、セル長領域
(21ビット)、リファレンスカウンタA領域(4ビッ
ト)、リファレンスカウンタB領域(4ビット)及び作
業フラグ(2ビット)の計32ビットで構成されるもの
とする。
The header part of the cell in the old garbage collection has a valid cell flag area (1 bit), a cell length area (25 bits) and a reference counter area (4 bits).
Bit) and work flag (2 bits), the header part of the cell in the new garbage collection is a valid cell flag area (1 bit), cell length area (21 bits), reference counter A area (4 bits). , A reference counter B area (4 bits) and a work flag (2 bits), a total of 32 bits.

【0144】<5-2.実験結果>図31は、シミュレー
ション実験による未解放のメモリ量(メモリを占有して
いるオブジェクト数)の時間的変化を示す図である。同
図から明らかなように、新ガベージコレクションの実行
頻度は旧ガベージコレクションの実行頻度より小さい。
<5-2. Experimental Results> FIG. 31 is a diagram showing temporal changes in the amount of unreleased memory (the number of objects occupying the memory) in the simulation experiment. As is clear from the figure, the execution frequency of the new garbage collection is lower than that of the old garbage collection.

【0145】この実験によれば、3万ステップ経過迄に
おけるガベージコレクション実行回数は、旧ガベージコ
レクションでは46回であるのに対し、新ガベージコレ
クションでは11回と少ないものとなった。なお、この
ときにおけるマークアンドスイープ処理とカウントアン
ドスイープ処理とのそれぞれの作業量を、各アルゴリズ
ムに由来するメモリアクセス回数に基づき推定して検証
すると、新ガベージコレクションは旧ガベージコレクシ
ョンの約4割の作業量であると算定された。
According to this experiment, the number of executions of garbage collection up to 30,000 steps is 46 in the old garbage collection and 11 in the new garbage collection. When the amount of work of the mark-and-sweep process and the count-and-sweep process at this time are estimated and verified based on the number of memory accesses derived from each algorithm, the new garbage collection is about 40% of the old garbage collection. It was calculated to be the amount of work.

【0146】従って、旧ガベージコレクションと比較す
れば、新ガベージコレクションは、アプリケーションプ
ログラムの実行性能にあまり悪影響を与えることなく、
効率的に不要なセルの回収を行うことを可能にする方式
であると言える。 <6.発明の効果>以上説明したことから明らかなよう
に、本発明に係るガベージコレクション装置は、アプリ
ケーションプログラムの実行によってメモリセルへの参
照状態が変更された時に、各メモリセル内に設けた被参
照カウンタを用いてリファレンスカウント方式によりガ
ベージコレクションを行うリファレンスカウント手段
と、アプリケーションプログラムの実行とは独立して1
以上のメモリセルについて、当該メモリセルが現実に参
照されている数を調査する独立カウント手段と、前記独
立カウント手段による調査結果である数を、対応するメ
モリセルの被参照カウンタに設定する設定手段とを備え
ることを特徴とする。
Therefore, compared with the old garbage collection, the new garbage collection does not adversely affect the execution performance of the application program, and
It can be said that this method enables efficient collection of unnecessary cells. <6. EFFECTS OF THE INVENTION> As is clear from the above description, the garbage collection device according to the present invention provides a referenced counter provided in each memory cell when the reference state to the memory cell is changed by the execution of the application program. Reference count means for performing a garbage collection by the reference count method by using the
For the above memory cells, independent count means for checking the number of actually referenced memory cells, and setting means for setting the number of the check result by the independent count means in the referenced counter of the corresponding memory cell. And is provided.

【0147】これにより、たとえ被参照カウンタがオー
バフローするようなことがあったとしても、セルが参照
されている数が実際上カウントされ被参照カウンタにあ
らためて設定されることにより被参照カウンタは正しい
値に修正され得るため、その後にはリファレンスカウン
ト方式のガベージコレクションによってポインタの変更
に伴いセルがどこからも参照されなくなった時点で即座
にそのセルが解放されるようになる。図29で示したよ
うにセルの被参照数がピーク値になった後、時間経過と
ともに安定値に落ち着く場合等、セルの被参照数が時間
経過につれて大きく変動するような場合においては、被
参照カウンタを安定値は表せるがピーク値は表せない程
度の小さなビット数で構成することとしても、本発明に
よればリファレンスカウント方式によるガベージコレク
ションが可能になる。
As a result, even if the referenced counter overflows, the number of cells being referenced is actually counted and set again in the referenced counter, so that the referenced counter has a correct value. Then, when the pointer is changed by the garbage collection of the reference counting method and the cell is no longer referenced from anywhere, the cell is immediately released. As shown in FIG. 29, in the case where the number of cells referred to largely fluctuates with time, such as when the number of cells referred to reaches a peak value and then settles to a stable value with time, the number of referred Even if the counter is configured with a small number of bits that can represent a stable value but not a peak value, the present invention enables garbage collection by the reference counting method.

【0148】ここで、前記各メモリセル内に設けられた
被参照カウンタは、当該メモリセルの被参照数を表すた
めの、1ワード未満の所定ビット数で構成され、前記リ
ファレンスカウント手段は、アプリケーションプログラ
ムの実行によってメモリセルへの参照状態が変更された
時に、当該メモリセルの被参照カウンタが前記所定ビッ
ト数で表せる最大値より小さい値であれば、当該被参照
カウンタを当該変更に応じて被参照数を表すように増加
又は減少させて、被参照カウンタの値が0になれば当該
メモリセルを解放し、前記独立カウント手段は、少なく
とも被参照カウンタが前記最大値である各メモリセルに
ついて前記調査を行うこととしてもよい。
Here, the referenced counter provided in each memory cell is composed of a predetermined bit number of less than one word for indicating the referenced number of the memory cell, and the reference counting means is an application. When the reference state of the memory cell is changed by the execution of the program and the value of the referenced counter of the memory cell is smaller than the maximum value that can be represented by the predetermined number of bits, the referenced counter is affected by the change. The reference count is incremented or decremented to release the memory cell when the value of the referenced counter reaches 0, and the independent count means is configured to perform the above-mentioned operation for at least each memory cell whose referenced counter has the maximum value. A survey may be conducted.

【0149】これにより、リファレンスカウント方式に
おいて、セルの被参照カウンタがオーバフローした場合
つまり被参照カウンタが既に最大値になっている場合に
はカウンタの増減を行わないようにしておくためポイン
タ変更時にどこからも参照されなくなったセルの解放は
行われないが、独立カウント手段及び設定手段により被
参照カウンタが現実にセルの被参照数を示すようにあら
ためて設定され得るため、設定された後にはセルはポイ
ンタ変更時にどこからも参照されなくなっていれば即座
に解放されるようになる。なお、セルの解放により、セ
ルに割り当てていたメモリ領域を新たにセルの生成のた
めに用いることが可能になる。
As a result, in the reference counting method, when the referenced counter of the cell overflows, that is, when the referenced counter has already reached the maximum value, the counter is not incremented or decremented. Although the cell that is no longer referred to is not released, the referenced counter can be set anew by the independent counting means and the setting means so as to actually indicate the referenced number of the cell. If it is no longer referenced by anyone when you change it, it will be released immediately. By releasing the cell, the memory area allocated to the cell can be used for generating a new cell.

【0150】また、前記メモリセル内には、独立カウン
ト手段による調査に用いるための前記所定ビット数の調
査用カウンタを設けてあり、前記独立カウント手段は、
調査対象のメモリセルの調査用カウンタを0にする初期
設定処理の後に、所定のルートポインタから直接又はポ
インタチェーンを介して指されている各メモリセルにつ
いての調査用カウンタを、前記所定ビット数で表せる最
大値を超えない範囲で、現実に指されている数を示すよ
うに増加するカウント処理を行うことにより前記調査を
行い、前記設定手段は、メモリセル毎に、当該メモリセ
ルの調査用カウンタの値を被参照カウンタに設定するこ
ととしてもよい。
Further, in the memory cell, there is provided a check counter having a predetermined number of bits for use in checking by the independent counting means, and the independent counting means is
After the initialization process for setting the investigation counter of the investigation target memory cell to 0, the investigation counter for each memory cell pointed to directly from the predetermined root pointer or through the pointer chain is set to the predetermined number of bits. The investigation is performed by performing a counting process that increases so as to indicate the number actually pointed to, within a range that does not exceed the maximum value that can be expressed, and the setting unit, for each memory cell, the investigation counter of the memory cell. The value of may be set in the referenced counter.

【0151】これにより、現実にセルが参照されている
数をカウントする処理を簡単に実現できる。ここで、被
参照カウンタは実施の形態において示したリファレンス
カウンタAに相当し、調査用カウンタはリファレンスカ
ウンタBに相当する。また、前記メモリセル内には、独
立カウント手段による調査状態が第1段階、第2段階及
び第3段階のいずれであるかを示すための作業フラグを
設けてあり、前記独立カウント手段は、全てのメモリセ
ルの作業フラグに第1段階を示す値を設定し、続いて前
記ルートポインタに指されているメモリセルの作業フラ
グに第2段階を示す値を設定し、第2段階を示す作業フ
ラグを含むメモリセルがある限り当該メモリセルに順次
着目して以下に示すカウントアップ処理を実行すること
により前記カウント処理を行い、前記カウントアップ処
理は、着目したメモリセルの作業フラグに第3段階を示
す値を設定し、当該メモリセルが他の1以上のメモリセ
ルへのポインタを含むときに当該他の全てのメモリセル
についての前記調査用カウンタを前記最大値を超えない
限りにおいて1増加するとともに、当該他のメモリセル
のうち作業フラグが第1段階を示すものについては作業
フラグに第2段階を示す値を設定する処理であり、前記
リファレンスカウント手段は、アプリケーションプログ
ラムの実行により、第3段階を示す作業フラグを含むメ
モリセルに含まれるポインタが変更された時に、変更前
のポインタが指していたメモリセルの調査用カウンタを
1減少するとともに、変更後のポインタが指すメモリセ
ルの調査用カウンタを前記最大値を超えない限りにおい
て1増加し、前記独立カウント手段は、前記調査をアプ
リケーションプログラムの実行と並行して行い、前記カ
ウントアップ処理の実行中はアプリケーションプログラ
ムの実行を抑止することとしてもよい。
This makes it possible to easily realize the process of counting the number of actually referenced cells. Here, the referenced counter corresponds to the reference counter A shown in the embodiment, and the investigation counter corresponds to the reference counter B. Further, in the memory cell, there is provided a work flag for indicating which one of the first stage, the second stage and the third stage the investigation state by the independent counting means is, and the independent counting means are all Value is set to the work flag of the memory cell, and the value indicating the second step is set to the work flag of the memory cell pointed to by the root pointer, and the work flag indicating the second step is set. As long as there is a memory cell including, the memory cell is sequentially focused and the following count-up processing is performed to perform the count processing, and the count-up processing sets the work flag of the focused memory cell to the third stage. When the memory cell includes a pointer to one or more other memory cells, the check counters for all the other memory cells are set to the maximum value. As long as the value does not exceed the value, the value is incremented by 1, and for the other memory cells whose work flag indicates the first stage, it is a process of setting the value indicating the second stage in the work flag, and the reference counting means. , When the pointer included in the memory cell including the work flag indicating the third stage is changed by the execution of the application program, the investigation counter of the memory cell pointed to by the pointer before the change is decremented by 1 and The counter for checking the memory cell pointed to by 1 is incremented by 1 as long as it does not exceed the maximum value, the independent count means performs the check in parallel with the execution of the application program, and while the count-up processing is being executed. The execution of the application program may be suppressed.

【0152】これにより、セルが現実に参照されている
数の調査を開始してから終了するまでの間に、アプリケ
ーションプログラムを動作させることができるようにな
る。また、前記メモリセル内には、独立カウント手段に
よる調査状態が第1段階及び第2段階のいずれであるか
を示すための作業フラグを設けてあり、前記独立カウン
ト手段は、メモリセルのアドレスをスタックに格納する
アルゴリズムを用いて、全てのメモリセルの作業フラグ
に第1段階を示す値を設定し、続いて前記ルートポイン
タに指されているメモリセルのアドレスをスタックに積
み、スタックにメモリセルのアドレスが積まれている限
り以下に示すカウントアップ処理を実行することにより
前記カウント処理を行い、前記カウントアップ処理は、
スタックから取り出したアドレスの示すメモリセルの作
業フラグに第2段階を示す値を設定し、当該メモリセル
が他の1以上のメモリセルへのポインタを含むときに当
該他の全てのメモリセルについての前記調査用カウンタ
を、前記最大値を超えない限り1増加するとともに、当
該他のメモリセルのうち作業フラグが第1段階を示すも
のについてはそのアドレスをスタックに積む処理であ
り、前記リファレンスカウント手段は、アプリケーショ
ンプログラムの実行により、第2段階を示す作業フラグ
を含むメモリセルに含まれるポインタが変更された時
に、変更前のポインタが指していたメモリセルの調査用
カウンタを1減少するとともに、変更後のポインタが指
すメモリセルの調査用カウンタを、前記最大値を超えな
い限りにおいて1増加し、前記独立カウント手段は、前
記調査をアプリケーションプログラムの実行と並行して
行い、前記カウントアップ処理の実行中はアプリケーシ
ョンプログラムの実行を抑止することとしてもよい。
As a result, the application program can be operated between the start and the end of the investigation of the number of cells actually referenced. A working flag is provided in the memory cell to indicate whether the investigation state by the independent counting means is in the first stage or the second stage. The independent counting means stores the address of the memory cell. Using the algorithm for storing in the stack, the work flags of all memory cells are set to values indicating the first stage, and subsequently, the addresses of the memory cells pointed to by the root pointer are stacked on the stack, and the memory cells are stacked on the stack. The count processing is performed by executing the count up processing shown below as long as the addresses of
A value indicating the second stage is set in the work flag of the memory cell indicated by the address fetched from the stack, and when the memory cell includes a pointer to one or more other memory cells, all the other memory cells This is a process of incrementing the check counter by 1 as long as it does not exceed the maximum value, and stacking the address of the other memory cells whose work flag indicates the first stage on the stack. When the pointer included in the memory cell including the work flag indicating the second stage is changed by the execution of the application program, the counter for decrementing the investigation counter of the memory cell pointed to by the pointer before the change is decremented by 1 and is changed. Increases the counter for checking the memory cell pointed to by the subsequent pointer by 1 as long as it does not exceed the maximum value , The independent counting unit performs in parallel the investigation and execution of the application program, during execution of the counting up process may be suppressed execution of the application program.

【0153】これにより、セルが現実に参照されている
数の調査を高速に行うことが可能になり、この調査とア
プリケーションプログラムの実行を並行して行うことが
できるようになる。また、前記ガベージコレクション装
置はさらに、前記独立カウント手段による調査結果であ
る数が0となっているメモリセルを解放する解放手段を
備え、前記設定手段は、前記調査結果である数が1以上
である場合に限り、前記設定を行うこととしてもよい。
As a result, it becomes possible to perform a high-speed check of the number of actually referenced cells, and this check and the execution of the application program can be performed in parallel. Further, the garbage collection device further comprises a releasing means for releasing a memory cell whose number of the inspection result by the independent counting means is 0, and the setting means, when the number of the inspection result is 1 or more. The above setting may be performed only in some cases.

【0154】これにより、セルが現実に参照されている
数の調査を行った結果として、被参照数が0であったセ
ルを解放することが可能になる。セルへのポインタのチ
ェーンがループしている場合にはセルをリファレンスカ
ウント方式のみでは解放できないが、このガベージコレ
クション装置によれば、ルートポインタから辿ることの
できない不要なセルを解放することが可能になる。
As a result of the investigation of the number of actually referenced cells, it is possible to release the cells whose referenced number is 0. When the chain of pointers to cells is looping, cells cannot be released only by the reference count method, but this garbage collection device makes it possible to release unnecessary cells that cannot be traced from the root pointer. Become.

【0155】また、前記独立カウント手段は、アプリケ
ーションプログラムの実行により確保されて参照される
各メモリセルが、参照されてから全く参照されなくなる
までの平均的な時間と予測される時間より短い時間毎
に、前記調査を行い、前記設定手段は、前記独立カウン
ト手段により調査が行われる度に前記設定を行うことと
してもよい。
Further, the independent counting means is arranged so that each memory cell secured and referred to by the execution of the application program is shorter than the time estimated from the average time from the reference to the complete non-reference. Further, the investigation may be performed, and the setting means may perform the setting each time the investigation is performed by the independent counting means.

【0156】これにより、半数以上のセルについて、確
保された後に一旦は被参照カウンタのオーバフローによ
りリファレンスカウント方式の活用が不可能になっても
そのセルが不要になる迄の期間内に、リファレンスカウ
ント方式によるガベージコレクションが活用できるよう
になり、そのセルが不要になると即座にセルの解放が行
えるようになるので、ガベージコレクション装置の実用
性が高まる。
As a result, for more than half of the cells, even if the reference count method cannot be used once due to the overflow of the referenced counter after it has been secured, the reference count is not reached within the period until the cells are no longer needed. Since the garbage collection by the method can be utilized and the cell can be released immediately when the cell is no longer needed, the practicality of the garbage collection apparatus is enhanced.

【0157】また、本発明に係るガベージコレクション
装置は、各メモリセル内に当該メモリセルの被参照数を
表すための、1ワード未満の所定ビット数の被参照カウ
ンタを設けておき、アプリケーションプログラムの実行
によってメモリセルへの参照状態が変更された時に、当
該メモリセルの被参照カウンタが前記所定ビット数で表
せる最大値より小さい値であれば、当該被参照カウンタ
を当該変更に応じて被参照数を表すように増加又は減少
させて、被参照カウンタの値が0になれば当該メモリセ
ルを解放するリファレンスカウント方式により、ガベー
ジコレクションを行うリファレンスカウント手段と、ア
プリケーションプログラムの実行とは独立して各メモリ
セルについて、当該メモリセルが現実に参照されている
数を調査する独立カウント手段であって、調査対象のメ
モリセルの被参照カウンタを0にする初期設定処理の後
に、所定のルートポインタから直接又はポインタチェー
ンを介して指されている各メモリセルについての被参照
カウンタを、前記所定ビット数で表せる最大値を超えな
い範囲で、現実に指されている数を示すように増加する
カウント処理を行う独立カウント手段とを備え、前記リ
ファレンスカウント手段は、前記独立カウント手段によ
り前記調査が行われている最中においては前記メモリセ
ルの解放を行わないようにすることを特徴とする。
Further, the garbage collection apparatus according to the present invention is provided with a referenced counter having a predetermined number of bits of less than one word for indicating the referenced number of the memory cell in each memory cell, so that the application program When the reference state of the memory cell is changed by execution, if the referenced counter of the memory cell is a value smaller than the maximum value that can be represented by the predetermined number of bits, the referenced counter is changed according to the change. The reference count method of performing garbage collection and the execution of the application program independently of each other by a reference count method of increasing or decreasing as indicated by For a memory cell, check the number of times the memory cell is actually referenced. The unreferenced counter for each memory cell pointed directly from the predetermined root pointer or via the pointer chain after the initialization processing for setting the referenced counter of the memory cell under investigation to 0. A reference count means for performing a count process of increasing to show a number actually pointed to within a range not exceeding a maximum value that can be represented by the predetermined number of bits, wherein the reference count means is It is characterized in that the memory cells are not released during the investigation.

【0158】これにより、リファレンスカウント方式に
おいて、セルの被参照カウンタがオーバフローした場合
つまり被参照カウンタが既に最大値になっている場合に
はカウンタの増減を行わないようにしておくためポイン
タ変更時にどこからも参照されなくなったセルの解放は
行われないが、独立カウント手段により被参照カウンタ
が現実にセルの被参照数を示すようにあらためて設定さ
れ得るため、設定された後にはセルはポインタ変更時に
どこからも参照されなくなっていれば即座に解放される
ようになる。また、独立カウント手段による現実のセル
の被参照数のカウントに被参照カウンタを用いるため、
このカウント専用のカウンタを設ける必要がなくなる。
As a result, in the reference counting method, when the referenced counter of the cell overflows, that is, when the referenced counter has already reached the maximum value, the counter is not incremented or decremented. Although the cell that is no longer referred to is not released, the reference counter can be set anew by the independent counting means to actually indicate the reference number of the cell. Will also be released immediately if no longer referenced. Further, since the referenced counter is used for counting the number of referenced cells in the actual cell by the independent counting means,
It is not necessary to provide a counter dedicated to this counting.

【0159】また、前記所定ビット数は、当該所定ビッ
トで表せる最大値がメモリセルの被参照数のピーク値と
予測される値より小さくなるように定めたビット数であ
ることとしてもよい。これにより、リファレンスカウン
ト用のカウンタの領域を小さなものにすることができる
ため、セル内にワード単位でセルの管理用の情報を設け
ることとした場合において、そのカウンタの領域を小さ
くした分だけ、例えばセル長等のセルの管理用の情報を
従来より大きなサイズでセル内に持たせることが可能に
なり、これにより例えば、アプリケーションプログラム
に対して確保を許容するセルサイズの拡大等を図ること
が可能になる。
The predetermined number of bits may be set so that the maximum value that can be represented by the predetermined bits is smaller than the value expected to be the peak value of the number of referenced memory cells. As a result, the area of the counter for reference count can be made small. Therefore, when providing the information for managing the cell in word units in the cell, the area of the counter is made smaller by For example, it becomes possible to store cell management information such as cell length in a cell having a larger size than in the past, and thereby, for example, to increase the cell size that is allowed to be secured for an application program. It will be possible.

【図面の簡単な説明】[Brief description of drawings]

【図1】本発明の実施の形態1に係るガベージコレクシ
ョン装置100の構成図である。
FIG. 1 is a configuration diagram of a garbage collection device 100 according to a first embodiment of the present invention.

【図2】セルのデータ構造を示す図である。FIG. 2 is a diagram showing a data structure of a cell.

【図3】メモリ300の一部の領域にセルが割り当てら
れている様子を示す図である。
FIG. 3 is a diagram showing how cells are assigned to a partial area of a memory 300.

【図4】ある時点におけるセルの内容とセル間の関係を
例示した図である。
FIG. 4 is a diagram exemplifying the contents of cells and relationships between cells at a certain time point.

【図5】セル確保部201が行うセル生成処理を示すフ
ローチャートである。
5 is a flowchart showing a cell generation process performed by a cell securing unit 201. FIG.

【図6】ガベージコレクション装置100の行うポイン
タ変更対応処理を示すフローチャートである。
FIG. 6 is a flowchart showing pointer change handling processing performed by the garbage collection device 100.

【図7】ガベージコレクション装置100の行うセル参
照解除処理を示すフローチャートである。
FIG. 7 is a flowchart showing a cell reference cancellation process performed by the garbage collection device 100.

【図8】ガベージコレクション装置100の行うカウン
トアンドスイープ処理を示すフローチャートである。
8 is a flowchart showing a count and sweep process performed by the garbage collection device 100. FIG.

【図9】カウントアンドスイープ処理におけるステップ
S502の終了直後のセルの内容とセル間の関係を例示
した図である。
FIG. 9 is a diagram exemplifying the content of cells and the relationship between cells immediately after the end of step S502 in the count and sweep process.

【図10】カウントアンドスイープ処理における1回目
のステップS508の実行の終了直後のセルの内容とセ
ル間の関係を例示した図である。
FIG. 10 is a diagram exemplifying the content of cells and the relationship between cells immediately after the first execution of step S508 in the count and sweep processing is completed.

【図11】カウントアンドスイープ処理における2回目
のステップS508の実行の終了直後のセルの内容とセ
ル間の関係を例示した図である。
FIG. 11 is a diagram exemplifying the content of cells and the relationship between cells immediately after the execution of step S508 for the second time in the count and sweep processing is completed.

【図12】カウントアンドスイープ処理においてS50
4のnoの分岐に進んだ直後のセルの内容とセル間の関
係を例示した図である。
FIG. 12: S50 in count and sweep processing
It is the figure which illustrated the content of the cell and the relationship between cells immediately after advancing to the branch of 4no.

【図13】カウントアンドスイープ処理の終了時点のセ
ルの内容とセル間の関係を例示した図である。
FIG. 13 is a diagram exemplifying the content of cells and the relationship between cells at the end of the count and sweep process.

【図14】変形ガベージコレクション装置が取り扱うセ
ルのデータ構造を示す図である。
FIG. 14 is a diagram showing a data structure of a cell handled by a modified garbage collection device.

【図15】実施の形態2におけるセルの作業用先頭セル
アドレス30からのポインタチェーンを例示する図であ
る。
FIG. 15 is a diagram exemplifying a pointer chain from a working head cell address 30 of a cell according to the second embodiment.

【図16】変形制御機構におけるセル確保部201が行
うセル生成処理を示すフローチャートである。
FIG. 16 is a flowchart showing a cell generation process performed by the cell securing unit 201 in the deformation control mechanism.

【図17】変形ガベージコレクション装置の行うカウン
トアンドスイープ処理を示すフローチャートである。
FIG. 17 is a flowchart showing a count-and-sweep process performed by the modified garbage collection device.

【図18】カウントアンドスイープ処理におけるステッ
プS701の終了直後のセルの内容とセル間の関係を例
示した図である。
FIG. 18 is a diagram exemplifying the content of cells and the relationship between cells immediately after the end of step S701 in the count and sweep process.

【図19】カウントアンドスイープ処理におけるステッ
プS702の実行の終了直後のセルの内容とセル間の関
係を例示した図である。
FIG. 19 is a diagram exemplifying the content of cells and the relationship between cells immediately after the end of execution of step S702 in the count and sweep processing.

【図20】カウントアンドスイープ処理におけるステッ
プS706の繰り返し処理が終わった直後のセルの内容
とセル間の関係を例示した図である。
FIG. 20 is a diagram exemplifying the content of cells and the relationship between cells immediately after the repetition processing of step S706 in the count and sweep processing is completed.

【図21】カウントアンドスイープ処理において再びス
テップS706が終わった直後のセルの内容とセル間の
関係を例示した図である。
FIG. 21 is a diagram exemplifying the content of cells and the relationship between cells immediately after step S706 is finished in the count and sweep process.

【図22】カウントアンドスイープ処理においてステッ
プS703のnoの分岐に進んだ直後のセルの内容とセ
ル間の関係を例示した図である。
FIG. 22 is a diagram exemplifying the content of cells and the relationship between cells immediately after proceeding to the no branch of step S703 in the count and sweep processing.

【図23】第2変形ガベージコレクション装置が取り扱
うセルのデータ構造を示す図である。
FIG. 23 is a diagram showing a data structure of a cell handled by the second modified garbage collection device.

【図24】第2変形ガベージコレクション装置の行うポ
インタ変更対応処理を示すフローチャートである。
FIG. 24 is a flowchart showing pointer change handling processing performed by the second modified garbage collection device.

【図25】第2変形ガベージコレクション装置の行うセ
ル参照解除処理を示すフローチャートである。
FIG. 25 is a flowchart showing cell reference cancellation processing performed by the second modified garbage collection device.

【図26】第2変形ガベージコレクション装置の行うカ
ウントアンドスイープ処理を示すフローチャートであ
る。
FIG. 26 is a flowchart showing a count-and-sweep process performed by the second modified garbage collection device.

【図27】従来のマークアンドスイープ方式を説明する
ための図である。
FIG. 27 is a diagram for explaining a conventional mark-and-sweep method.

【図28】従来のリファレンスカウント方式を説明する
ための図である。
FIG. 28 is a diagram for explaining a conventional reference counting method.

【図29】Javaにおける典型的なセルへの参照数の
時間的変化を示すグラフである。
FIG. 29 is a graph showing changes over time in the number of references to a typical cell in Java.

【図30】シミュレーション実験における前提となるセ
ルへの参照数の時間的変化を示すグラフである。
FIG. 30 is a graph showing a temporal change in the number of references to cells, which is a premise in a simulation experiment.

【図31】シミュレーション実験による未解放のメモリ
量(メモリを占有しているオブジェクト数)の時間的変
化を示す図である。
FIG. 31 is a diagram showing a temporal change in the amount of unreleased memory (the number of objects occupying memory) by a simulation experiment.

【符号の説明】[Explanation of symbols]

100 ガベージコレクション装置 110 カウンタ変更部 111 カウンタ最大値判定部 112 カウンタ増加部 113 カウンタ減少部 120 カウンタゼロ判定部 130 セル解放部 140 再カウント部 141 再カウント結果ゼロ判定部 142 カウンタ再設定部 200 制御機構 201 セル確保部 202 ポインタ設定部 210 カウントアンドスイープ指示部 300 メモリ 1100、2100、3100 セル 1101、2101、3101 有効セルフラグ領域 1102、2102、3102 セル長領域 1103、2103 リファレンスカウン
タA領域 1104、2104 リファレンスカウン
タB領域 1105、2105、3104 作業フラグ領域 1106、2107、3105 データ領域 2106 作業用領域 3103 リファレンスカウンタ領域
100 garbage collection device 110 counter changing unit 111 maximum counter value determining unit 112 counter increasing unit 113 counter decreasing unit 120 counter zero determining unit 130 cell releasing unit 140 recounting unit 141 recounting result zero determining unit 142 counter resetting unit 200 control mechanism 201 cell securing unit 202 pointer setting unit 210 count and sweep instructing unit 300 memory 1100, 2100, 3100 cell 1101, 2101, 3101 valid cell flag area 1102, 2102, 3102 cell length area 1103, 2103 reference counter A area 1104, 2104 reference counter B area 1105, 2105, 3104 Work flag area 1106, 2107, 3105 Data area 2106 Work area 3103 Reference count Area

───────────────────────────────────────────────────── フロントページの続き (72)発明者 川本 ▲たく▼二 愛知県名古屋市中区栄2丁目6番1号 白 川ビル別館5階 株式会社松下電器情報シ ステム名古屋研究所内 Fターム(参考) 5B060 AA10    ─────────────────────────────────────────────────── ─── Continued front page    (72) Inventor Kawamoto ▲ Taku ▼ 2             2-6-1, Sakae, Naka-ku, Nagoya-shi, Aichi             Kawa Building Annex 5th floor Matsushita Electric Information Co., Ltd.             Stem Nagoya Institute F-term (reference) 5B060 AA10

Claims (16)

【特許請求の範囲】[Claims] 【請求項1】 アプリケーションプログラムの実行によ
ってメモリセルへの参照状態が変更された時に、各メモ
リセル内に設けた被参照カウンタを用いてリファレンス
カウント方式によりガベージコレクションを行うリファ
レンスカウント手段と、 アプリケーションプログラムの実行とは独立して1以上
のメモリセルについて、当該メモリセルが現実に参照さ
れている数を調査する独立カウント手段と、 前記独立カウント手段による調査結果である数を、対応
するメモリセルの被参照カウンタに設定する設定手段と
を備えることを特徴とするガベージコレクション装置。
1. A reference counting means for performing garbage collection by a reference counting method using a referenced counter provided in each memory cell when a reference state to the memory cell is changed by executing the application program, and an application program. Independent counting means for checking the number of actually referenced memory cells for one or more memory cells independently of the execution of A garbage collection device, comprising: setting means for setting a referenced counter.
【請求項2】 前記各メモリセル内に設けられた被参照
カウンタは、当該メモリセルの被参照数を表すための、
1ワード未満の所定ビット数で構成され、 前記リファレンスカウント手段は、アプリケーションプ
ログラムの実行によってメモリセルへの参照状態が変更
された時に、当該メモリセルの被参照カウンタが前記所
定ビット数で表せる最大値より小さい値であれば、当該
被参照カウンタを当該変更に応じて被参照数を表すよう
に増加又は減少させて、被参照カウンタの値が0になれ
ば当該メモリセルを解放し、 前記独立カウント手段は、少なくとも被参照カウンタが
前記最大値である各メモリセルについて前記調査を行う
ことを特徴とする請求項1記載のガベージコレクション
装置。
2. A referenced counter provided in each memory cell, for indicating a referenced number of the memory cell,
The reference count means comprises a predetermined number of bits less than one word, and when the reference state to the memory cell is changed by execution of an application program, the reference count means is a maximum value that the referenced counter of the memory cell can represent by the predetermined number of bits. If the value is smaller, the referenced counter is incremented or decremented to represent the referenced number according to the change, and when the value of the referenced counter becomes 0, the memory cell is released, and the independent count is performed. 2. The garbage collection apparatus according to claim 1, wherein the means performs the check on each memory cell whose referenced counter is at least the maximum value.
【請求項3】 前記メモリセル内には、独立カウント手
段による調査に用いるための前記所定ビット数の調査用
カウンタを設けてあり、 前記独立カウント手段は、 調査対象のメモリセルの調査用カウンタを0にする初期
設定処理の後に、 所定のルートポインタから直接又はポインタチェーンを
介して指されている各メモリセルについての調査用カウ
ンタを、前記所定ビット数で表せる最大値を超えない範
囲で、現実に指されている数を示すように増加するカウ
ント処理を行うことにより前記調査を行い、 前記設定手段は、メモリセル毎に、当該メモリセルの調
査用カウンタの値を被参照カウンタに設定することを特
徴とする請求項2記載のガベージコレクション装置。
3. A check counter of the predetermined number of bits for use in checking by the independent counting means is provided in the memory cell, and the independent counting means is a check counter of the memory cell to be checked. After the initialization processing for setting the value to 0, the investigation counter for each memory cell pointed to directly from the predetermined root pointer or via the pointer chain is actually set within the maximum value that can be represented by the predetermined number of bits. The investigation is performed by performing a counting process that increases so as to indicate the number pointed to by, and the setting unit sets, for each memory cell, the value of the investigation counter of the memory cell in the referenced counter. The garbage collection device according to claim 2.
【請求項4】 前記メモリセル内には、独立カウント手
段による調査状態が第1段階、第2段階及び第3段階の
いずれであるかを示すための作業フラグを設けてあり、 前記独立カウント手段は、 全てのメモリセルの作業フラグに第1段階を示す値を設
定し、続いて前記ルートポインタに指されているメモリ
セルの作業フラグに第2段階を示す値を設定し、 第2段階を示す作業フラグを含むメモリセルがある限り
当該メモリセルに順次着目して以下に示すカウントアッ
プ処理を実行することにより前記カウント処理を行い、 前記カウントアップ処理は、着目したメモリセルの作業
フラグに第3段階を示す値を設定し、当該メモリセルが
他の1以上のメモリセルへのポインタを含むときに当該
他の全てのメモリセルについての前記調査用カウンタを
前記最大値を超えない限りにおいて1増加するととも
に、当該他のメモリセルのうち作業フラグが第1段階を
示すものについては作業フラグに第2段階を示す値を設
定する処理であり、 前記リファレンスカウント手段は、アプリケーションプ
ログラムの実行により、第3段階を示す作業フラグを含
むメモリセルに含まれるポインタが変更された時に、変
更前のポインタが指していたメモリセルの調査用カウン
タを1減少するとともに、変更後のポインタが指すメモ
リセルの調査用カウンタを前記最大値を超えない限りに
おいて1増加し、 前記独立カウント手段は、前記調査をアプリケーション
プログラムの実行と並行して行い、前記カウントアップ
処理の実行中はアプリケーションプログラムの実行を抑
止することを特徴とする請求項3記載のガベージコレク
ション装置。
4. A work flag is provided in the memory cell to indicate whether the investigation state by the independent counting means is the first stage, the second stage or the third stage. Sets the work flags of all the memory cells to the value indicating the first step, then sets the work flags of the memory cells pointed to by the root pointers to the values indicating the second step, and sets the second step. As long as there is a memory cell including the work flag shown, the count process is performed by sequentially focusing on the memory cell and executing the count-up process shown below. A value indicating three stages is set, and when the memory cell includes a pointer to one or more other memory cells, the investigation count for all the other memory cells is set. Is incremented by 1 as long as it does not exceed the maximum value, and the work flag of the other memory cells indicates the first stage, the work flag is set to a value indicating the second stage. When the pointer included in the memory cell including the work flag indicating the third stage is changed by the execution of the application program, the counting means decrements the investigation counter of the memory cell pointed to by the pointer before the change by 1 and The count counter of the memory cell pointed to by the changed pointer is incremented by 1 as long as it does not exceed the maximum value, and the independent count means performs the check in parallel with the execution of the application program, The execution of an application program is suppressed during execution. The placement of garbage collection equipment.
【請求項5】 前記メモリセル内には、独立カウント手
段による調査状態が第1段階及び第2段階のいずれであ
るかを示すための作業フラグを設けてあり、前記独立カ
ウント手段は、 メモリセルのアドレスをスタックに格納するアルゴリズ
ムを用いて、 全てのメモリセルの作業フラグに第1段階を示す値を設
定し、続いて前記ルートポインタに指されているメモリ
セルのアドレスをスタックに積み、 スタックにメモリセルのアドレスが積まれている限り以
下に示すカウントアップ処理を実行することにより前記
カウント処理を行い、 前記カウントアップ処理は、スタックから取り出したア
ドレスの示すメモリセルの作業フラグに第2段階を示す
値を設定し、当該メモリセルが他の1以上のメモリセル
へのポインタを含むときに当該他の全てのメモリセルに
ついての前記調査用カウンタを、前記最大値を超えない
限り1増加するとともに、当該他のメモリセルのうち作
業フラグが第1段階を示すものについてはそのアドレス
をスタックに積む処理であり、 前記リファレンスカウント手段は、アプリケーションプ
ログラムの実行により、第2段階を示す作業フラグを含
むメモリセルに含まれるポインタが変更された時に、変
更前のポインタが指していたメモリセルの調査用カウン
タを1減少するとともに、変更後のポインタが指すメモ
リセルの調査用カウンタを、前記最大値を超えない限り
において1増加し、 前記独立カウント手段は、前記調査をアプリケーション
プログラムの実行と並行して行い、前記カウントアップ
処理の実行中はアプリケーションプログラムの実行を抑
止することを特徴とする請求項3記載のガベージコレク
ション装置。
5. A working flag is provided in the memory cell to indicate whether the investigation state by the independent counting means is the first stage or the second stage, and the independent counting means is a memory cell. Using the algorithm of storing the addresses of the above in the stack, set the work flag of all memory cells to the value indicating the first stage, and then stack the addresses of the memory cells pointed to by the root pointer into the stack. The count processing is performed by executing the following count-up processing as long as the memory cell address is loaded in the memory cell, and the count-up processing is performed in the second stage in the work flag of the memory cell indicated by the address taken out from the stack. Is set, and when the memory cell contains a pointer to one or more other memory cells, all other memory cells This is a process of incrementing the check counter for a memory cell by 1 as long as it does not exceed the maximum value, and stacking the address of the other memory cells whose work flag indicates the first stage on the stack. When the pointer included in the memory cell including the work flag indicating the second stage is changed by the execution of the application program, the reference counting means decrements the investigation counter of the memory cell pointed to by the pointer before the change by one. In addition, the investigation counter of the memory cell pointed to by the changed pointer is incremented by 1 as long as it does not exceed the maximum value, and the independent counting means performs the investigation in parallel with the execution of the application program, Suppress execution of application programs during execution of up processing DOO garbage collection apparatus according to claim 3, wherein.
【請求項6】 前記ガベージコレクション装置はさら
に、前記独立カウント手段による調査結果である数が0
となっているメモリセルを解放する解放手段を備え、 前記設定手段は、前記調査結果である数が1以上である
場合に限り、前記設定を行うことを特徴とする請求項1
記載のガベージコレクション装置。
6. The garbage collection device is further provided with a number 0 which is a result of the investigation by the independent counting means.
2. The release means is provided for releasing the memory cell that has become, and the setting means performs the setting only when the number as the investigation result is 1 or more.
Garbage collection device as described.
【請求項7】 前記独立カウント手段は、アプリケーシ
ョンプログラムの実行により確保されて参照される各メ
モリセルが、参照されてから全く参照されなくなるまで
の平均的な時間と予測される時間より短い時間毎に、前
記調査を行い、 前記設定手段は、前記独立カウント手段により調査が行
われる度に前記設定を行うことを特徴とする請求項1記
載のガベージコレクション装置。
7. The independent count means is arranged such that each memory cell secured and referred to by the execution of the application program is shorter than an average time from a reference time to a non-reference time, which is shorter than a predicted time. 2. The garbage collection apparatus according to claim 1, wherein the survey is performed, and the setting unit performs the setting each time the independent counting unit surveys.
【請求項8】 各メモリセル内に当該メモリセルの被参
照数を表すための、1ワード未満の所定ビット数の被参
照カウンタを設けておき、アプリケーションプログラム
の実行によってメモリセルへの参照状態が変更された時
に、当該メモリセルの被参照カウンタが前記所定ビット
数で表せる最大値より小さい値であれば、当該被参照カ
ウンタを当該変更に応じて被参照数を表すように増加又
は減少させて、被参照カウンタの値が0になれば当該メ
モリセルを解放するリファレンスカウント方式により、
ガベージコレクションを行うリファレンスカウント手段
と、 アプリケーションプログラムの実行とは独立して各メモ
リセルについて、当該メモリセルが現実に参照されてい
る数を調査する独立カウント手段であって、調査対象の
メモリセルの被参照カウンタを0にする初期設定処理の
後に、所定のルートポインタから直接又はポインタチェ
ーンを介して指されている各メモリセルについての被参
照カウンタを、前記所定ビット数で表せる最大値を超え
ない範囲で、現実に指されている数を示すように増加す
るカウント処理を行う独立カウント手段とを備え、 前記リファレンスカウント手段は、前記独立カウント手
段により前記調査が行われている最中においては前記メ
モリセルの解放を行わないようにすることを特徴とする
ガベージコレクション装置。
8. A referenced counter having a predetermined number of bits of less than one word is provided in each memory cell to represent the referenced number of the memory cell, and a reference state to the memory cell is set by executing an application program. If the referenced counter of the memory cell is smaller than the maximum value that can be represented by the predetermined number of bits when changed, the referenced counter is increased or decreased to represent the referenced number according to the change. , When the value of the referenced counter becomes 0, the reference counting method that releases the memory cell is
A reference counting unit that performs garbage collection and an independent counting unit that checks the number of actually referenced memory cells for each memory cell independently of the execution of the application program. After the initialization process of setting the referenced counter to 0, the referenced counter for each memory cell pointed to directly by a predetermined route pointer or through the pointer chain does not exceed the maximum value that can be represented by the predetermined number of bits. In a range, an independent count means for performing a counting process to increase so as to indicate the number actually pointed to, the reference count means, the independent count means, while the investigation is being performed by the independent count means Garbage collection characterized by not releasing memory cells ® down apparatus.
【請求項9】 前記ガベージコレクション装置はさら
に、前記独立カウント手段による調査結果である数が0
となっているメモリセルを解放する解放手段を備えるこ
とを特徴とする請求項8記載のガベージコレクション装
置。
9. The garbage collection device is further provided with a number 0 as a result of the investigation by the independent counting means.
9. The garbage collection device according to claim 8, further comprising a releasing means for releasing the memory cell that has become a memory cell.
【請求項10】 前記所定ビット数は、当該所定ビット
で表せる最大値がメモリセルの被参照数のピーク値と予
測される値より小さくなるように定めたビット数である
ことを特徴とする請求項2又は8に記載のガベージコレ
クション装置。
10. The predetermined number of bits is a number of bits determined such that a maximum value represented by the predetermined bits is smaller than a value expected to be a peak value of the number of referenced memory cells. Item 2. The garbage collection device according to item 2 or 8.
【請求項11】 アプリケーションプログラムの実行に
よってメモリセルへの参照状態が変更された時に、各メ
モリセル内に設けられた被参照カウンタを用いてリファ
レンスカウント方式によりガベージコレクションを行う
リファレンスカウントステップと、 アプリケーションプログラムの実行とは独立して1以上
のメモリセルについて、当該メモリセルが現実に参照さ
れている数を調査する独立カウントステップと、 前記独立カウントステップによる調査結果である数を、
対応するメモリセルの被参照カウンタに設定する設定ス
テップとを含むことを特徴とするガベージコレクション
方法。
11. A reference counting step of performing garbage collection by a reference counting method using a referenced counter provided in each memory cell when a reference state to the memory cell is changed by executing an application program, and an application. Independently from the execution of the program, for one or more memory cells, an independent count step of checking the number of actually referenced memory cells, and a number obtained by the independent count step are
And a setting step of setting a referenced counter of a corresponding memory cell.
【請求項12】 アプリケーションプログラムにより確
保され利用され得る各メモリセル内に当該メモリセルの
被参照数を表すための、1ワード未満の所定ビット数の
被参照カウンタを設けたアプリケーションプログラム実
行環境において、メモリセルのガベージコレクションを
行うためのガベージコレクション方法であって、 アプリケーションプログラムの実行によってメモリセル
への参照状態が変更された時に、当該メモリセルの被参
照カウンタが前記所定ビット数で表せる最大値より小さ
い値であれば、当該被参照カウンタを当該変更に応じて
被参照数を表すように増加又は減少させて、被参照カウ
ンタの値が0になれば当該メモリセルを解放するリファ
レンスカウント方式により、ガベージコレクションを行
うリファレンスカウントステップと、 アプリケーションプログラムの実行とは独立して各メモ
リセルについて、当該メモリセルが現実に参照されてい
る数を調査する独立カウントステップであって、調査対
象のメモリセルの被参照カウンタを0にする初期設定処
理の後に、所定のルートポインタから直接又はポインタ
チェーンを介して指されている各メモリセルについての
被参照カウンタを、前記所定ビット数で表せる最大値を
超えない範囲で、現実に指されている数を示すように増
加するカウント処理を行う独立カウントステップとを含
み、 前記リファレンスカウントステップは、前記独立カウン
トステップにより前記調査が行われている最中において
は前記メモリセルの解放を行わないようにすることを特
徴とするガベージコレクション方法。
12. An application program execution environment in which a referenced counter having a predetermined number of bits of less than 1 word is provided in each memory cell that can be reserved and used by an application program and represents the referenced number of the memory cell. A garbage collection method for performing a garbage collection of a memory cell, wherein when the reference state to the memory cell is changed by the execution of the application program, the referenced counter of the memory cell has a value larger than the maximum value that can be represented by the predetermined number of bits. If the value is small, the referenced counter is incremented or decremented so as to represent the referenced number according to the change, and when the value of the referenced counter becomes 0, the memory cell is released by the reference count method. Reference count for garbage collection This is an independent count step of checking the number of actually referenced memory cells for each memory cell independently of the execution of the application program and the step, and sets the referenced counter of the memory cell to be checked to 0. After the initial setting process, the referenced counter for each memory cell pointed directly or through the pointer chain from the predetermined root pointer is actually pointed to within the maximum value that can be represented by the predetermined number of bits. And an independent count step of performing a count process that increases so as to indicate the number of the memory cells, wherein the reference count step releases the memory cell during the investigation by the independent count step. Garbage collection method characterized by avoiding.
【請求項13】 コンピュータにガベージコレクション
処理を行わせるための制御プログラムであって、 前記ガベージコレクション処理は、 アプリケーションプログラムの実行によってメモリセル
への参照状態が変更された時に、各メモリセル内に設け
た被参照カウンタを用いてリファレンスカウント方式に
よりガベージコレクションを行うリファレンスカウント
ステップと、 アプリケーションプログラムの実行とは独立して1以上
のメモリセルについて、当該メモリセルが現実に参照さ
れている数を調査する独立カウントステップと、 前記独立カウントステップによる調査結果である数を、
対応するメモリセルの被参照カウンタに設定する設定ス
テップとを含むことを特徴とする制御プログラム。
13. A control program for causing a computer to perform a garbage collection process, wherein the garbage collection process is provided in each memory cell when a reference state to the memory cell is changed by execution of an application program. The reference count step of performing the garbage collection by the reference count method using the referenced counter and the number of actually referenced memory cells are investigated for one or more memory cells independently of the execution of the application program. Independent counting step, the number that is the result of the survey by the independent counting step,
And a setting step for setting a referenced counter of a corresponding memory cell.
【請求項14】 アプリケーションプログラムにより確
保され利用され得る各メモリセル内に当該メモリセルの
被参照数を表すための、1ワード未満の所定ビット数の
被参照カウンタを設けたアプリケーションプログラム実
行環境として機能するコンピュータに、ガベージコレク
ション処理を行わせるための制御プログラムであって、 前記ガベージコレクション処理は、 アプリケーションプログラムの実行によってメモリセル
への参照状態が変更された時に、当該メモリセルの被参
照カウンタが前記所定ビット数で表せる最大値より小さ
い値であれば、当該被参照カウンタを当該変更に応じて
被参照数を表すように増加又は減少させて、被参照カウ
ンタの値が0になれば当該メモリセルを解放するリファ
レンスカウント方式により、ガベージコレクションを行
うリファレンスカウントステップと、 アプリケーションプログラムの実行とは独立して各メモ
リセルについて、当該メモリセルが現実に参照されてい
る数を調査する独立カウントステップであって、調査対
象のメモリセルの被参照カウンタを0にする初期設定処
理の後に、所定のルートポインタから直接又はポインタ
チェーンを介して指されている各メモリセルについての
被参照カウンタを、前記所定ビット数で表せる最大値を
超えない範囲で、現実に指されている数を示すように増
加するカウント処理を行う独立カウントステップとを含
み、 前記リファレンスカウントステップは、前記独立カウン
トステップにより前記調査が行われている最中において
は前記メモリセルの解放を行わないようにすることを特
徴とする制御プログラム。
14. An application program execution environment provided with a referenced counter having a predetermined number of bits of less than one word for representing the referenced number of the memory cell in each memory cell that can be reserved and used by the application program. A control program for causing a computer to perform a garbage collection process, wherein the garbage collection process, when a reference state to a memory cell is changed by execution of an application program, a referenced counter of the memory cell is If the value is smaller than the maximum value that can be represented by a predetermined number of bits, the referenced counter is incremented or decremented to represent the referenced number according to the change, and if the referenced counter value becomes 0, the memory cell concerned. By the reference counting method to release the The reference counting step of performing the retraction and the independent counting step of investigating the number of actually referenced memory cells for each memory cell independently of the execution of the application program. A range that does not exceed the maximum value that can be represented by the predetermined number of bits for the referenced counter for each memory cell pointed directly by a predetermined route pointer or through the pointer chain after the initialization processing for setting the reference counter to 0. In the above, the reference counting step includes an independent counting step that performs a counting process that increases so as to indicate the number actually pointed to, and the reference counting step includes the memory during the investigation by the independent counting step. Control characterized by not releasing the cell program.
【請求項15】 コンピュータにガベージコレクション
処理を行わせるための制御プログラムを記録したコンピ
ュータ読み取り可能な記録媒体であって、前記ガベージ
コレクション処理は、 アプリケーションプログラムの実行によってメモリセル
への参照状態が変更された時に、各メモリセル内に設け
た被参照カウンタを用いてリファレンスカウント方式に
よりガベージコレクションを行うリファレンスカウント
ステップと、 アプリケーションプログラムの実行とは独立して1以上
のメモリセルについて、当該メモリセルが現実に参照さ
れている数を調査する独立カウントステップと、 前記独立カウントステップによる調査結果である数を、
対応するメモリセルの被参照カウンタに設定する設定ス
テップとを含むことを特徴とする記録媒体。
15. A computer-readable recording medium recording a control program for causing a computer to perform a garbage collection process, wherein in the garbage collection process, a reference state to a memory cell is changed by execution of an application program. In this case, the reference count step of performing the garbage collection by the reference count method using the referenced counter provided in each memory cell, and the execution of the application program independently of one or more memory cells, An independent counting step for investigating the number referred to in
And a setting step for setting a referenced counter of a corresponding memory cell.
【請求項16】 アプリケーションプログラムにより確
保され利用され得る各メモリセル内に当該メモリセルの
被参照数を表すための、1ワード未満の所定ビット数の
被参照カウンタを設けたアプリケーションプログラム実
行環境として機能するコンピュータに、ガベージコレク
ション処理を行わせるための制御プログラムを記録した
コンピュータ読み取り可能な記録媒体であって、 前記ガベージコレクション処理は、 アプリケーションプログラムの実行によってメモリセル
への参照状態が変更された時に、当該メモリセルの被参
照カウンタが前記所定ビット数で表せる最大値より小さ
い値であれば、当該被参照カウンタを当該変更に応じて
被参照数を表すように増加又は減少させて、被参照カウ
ンタの値が0になれば当該メモリセルを解放するリファ
レンスカウント方式により、ガベージコレクションを行
うリファレンスカウントステップと、 アプリケーションプログラムの実行とは独立して各メモ
リセルについて、当該メモリセルが現実に参照されてい
る数を調査する独立カウントステップであって、調査対
象のメモリセルの被参照カウンタを0にする初期設定処
理の後に、所定のルートポインタから直接又はポインタ
チェーンを介して指されている各メモリセルについての
被参照カウンタを、前記所定ビット数で表せる最大値を
超えない範囲で、現実に指されている数を示すように増
加するカウント処理を行う独立カウントステップとを含
み、 前記リファレンスカウントステップは、前記独立カウン
トステップにより前記調査が行われている最中において
は前記メモリセルの解放を行わないようにすることを特
徴とする記録媒体。
16. A function as an application program execution environment, wherein a referenced counter having a predetermined number of bits less than one word is provided in each memory cell that is secured and can be used by an application program to represent the referenced number of the memory cell. A computer-readable recording medium recording a control program for causing a computer to perform a garbage collection process, wherein the garbage collection process, when a reference state to a memory cell is changed by execution of an application program, If the referenced counter of the memory cell is smaller than the maximum value that can be represented by the predetermined number of bits, the referenced counter is incremented or decremented to represent the referenced number according to the change, and the referenced counter is Release the memory cell when the value becomes 0 By the reference count method, a reference counting step for performing garbage collection and an independent counting step for investigating the number of actually referenced memory cells for each memory cell independently of the execution of the application program, After the initialization process of setting the referenced counter of the memory cell to be investigated to 0, the referenced counter for each memory cell pointed to directly by a predetermined root pointer or through the pointer chain is set to the predetermined number of bits. In a range that does not exceed the maximum value that can be represented, including an independent counting step that performs a counting process that increases so as to indicate the number actually pointed, the reference counting step, the reference is performed by the independent counting step. In the middle of A recording medium characterized by being prevented from being released.
JP2002154671A 2001-05-29 2002-05-28 Garbage collection apparatus and garbage collection method Expired - Fee Related JP4041347B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2002154671A JP4041347B2 (en) 2001-05-29 2002-05-28 Garbage collection apparatus and garbage collection method

Applications Claiming Priority (3)

Application Number Priority Date Filing Date Title
JP2001-160519 2001-05-29
JP2001160519 2001-05-29
JP2002154671A JP4041347B2 (en) 2001-05-29 2002-05-28 Garbage collection apparatus and garbage collection method

Publications (2)

Publication Number Publication Date
JP2003050740A true JP2003050740A (en) 2003-02-21
JP4041347B2 JP4041347B2 (en) 2008-01-30

Family

ID=26615859

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2002154671A Expired - Fee Related JP4041347B2 (en) 2001-05-29 2002-05-28 Garbage collection apparatus and garbage collection method

Country Status (1)

Country Link
JP (1) JP4041347B2 (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005100402A (en) * 2003-09-23 2005-04-14 Microsoft Corp Area based memory management for object-oriented program
JP2013239156A (en) * 2012-05-15 2013-11-28 Internatl Business Mach Corp <Ibm> Method, apparatus, and computer program for managing memory
JP2014529142A (en) * 2011-09-09 2014-10-30 マイクロソフト コーポレーション Managing object life in a cyclic graph
US9098319B2 (en) 2012-09-20 2015-08-04 International Business Machines Corporation Code conversion method, program, and system for garbage collection
CN109690485A (en) * 2018-08-24 2019-04-26 袁振南 Rubbish recovering method, computer and storage medium based on data structure

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR102233476B1 (en) * 2019-01-25 2021-03-29 서울대학교산학협력단 Method for managing memory and apparatus therefor

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005100402A (en) * 2003-09-23 2005-04-14 Microsoft Corp Area based memory management for object-oriented program
JP2014529142A (en) * 2011-09-09 2014-10-30 マイクロソフト コーポレーション Managing object life in a cyclic graph
US9613073B2 (en) 2011-09-09 2017-04-04 Microsoft Technology Licensing, Llc Managing object lifetime in a cyclic graph
JP2013239156A (en) * 2012-05-15 2013-11-28 Internatl Business Mach Corp <Ibm> Method, apparatus, and computer program for managing memory
US9575879B2 (en) 2012-05-15 2017-02-21 International Business Machines Corporation Managing memory in a computer system
US10031843B2 (en) 2012-05-15 2018-07-24 International Business Machines Corporation Managing memory in a computer system
US10037269B2 (en) 2012-05-15 2018-07-31 International Business Machines Corporation Managing memory in a computer system
US10372601B2 (en) 2012-05-15 2019-08-06 International Business Machines Corporation Managing memory in a computer system
US10909029B2 (en) 2012-05-15 2021-02-02 International Business Machines Corporation Managing memory in a computer system
US9098319B2 (en) 2012-09-20 2015-08-04 International Business Machines Corporation Code conversion method, program, and system for garbage collection
CN109690485A (en) * 2018-08-24 2019-04-26 袁振南 Rubbish recovering method, computer and storage medium based on data structure
CN109690485B (en) * 2018-08-24 2023-08-18 袁振南 Garbage collection method based on data structure, computer and storage medium

Also Published As

Publication number Publication date
JP4041347B2 (en) 2008-01-30

Similar Documents

Publication Publication Date Title
JP3027845B2 (en) Program control device and method
US6571260B1 (en) Memory reclamation method
US8255658B2 (en) Memory management method and computer using the same
US7167881B2 (en) Method for heap memory management and computer system using the same method
EP2175370B1 (en) System and method of using pooled thread-local character arrays
JP4265610B2 (en) Program control apparatus, program control method, and program recording medium
US9740716B2 (en) System and method for dynamically selecting a garbage collection algorithm based on the contents of heap regions
US8397045B2 (en) Memory management device, memory management method, and memory management program
JP2003519834A (en) Method and apparatus for improving locality of reference by memory management
US20140115291A1 (en) Numa optimization for garbage collection of multi-threaded applications
US7676511B2 (en) Method and apparatus for reducing object pre-tenuring overhead in a generational garbage collector
US8966212B2 (en) Memory management method, computer system and computer readable medium
JP4333676B2 (en) Program control apparatus, program control method, and program recording medium
KR102114245B1 (en) Graphics state manage apparatus and method
JP4041347B2 (en) Garbage collection apparatus and garbage collection method
US6735761B1 (en) Compile method frame detection method and device code discarding method and computer
US7991976B2 (en) Permanent pool memory management method and system
JP5051961B2 (en) Method and apparatus for implementing a modular garbage collector
US8990532B2 (en) Method of managing memory in computer system, computer system and memory managing program
US7155467B1 (en) Adaptive type-partitioned garbage collection
JP2004295889A (en) Method and device for controlling execution of processing task within data processing system
CN100468346C (en) Drawing resource management method and system
US7596667B1 (en) Method and apparatus for byte allocation accounting in a system having a multi-threaded application and a generational garbage collector that dynamically pre-tenures objects
CN106354624B (en) Automatic testing method and device
JP2000099351A (en) Program controller and memory allocation device and method

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20050311

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20070809

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20070821

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20070912

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20071016

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20071109

FPAY Renewal fee payment (prs date is renewal date of database)

Free format text: PAYMENT UNTIL: 20101116

Year of fee payment: 3

R150 Certificate of patent (=grant) or registration of utility model

Free format text: JAPANESE INTERMEDIATE CODE: R150

LAPS Cancellation because of no payment of annual fees