Nothing Special   »   [go: up one dir, main page]

JP2001101070A - Memory management method and memory management device - Google Patents

Memory management method and memory management device

Info

Publication number
JP2001101070A
JP2001101070A JP28253699A JP28253699A JP2001101070A JP 2001101070 A JP2001101070 A JP 2001101070A JP 28253699 A JP28253699 A JP 28253699A JP 28253699 A JP28253699 A JP 28253699A JP 2001101070 A JP2001101070 A JP 2001101070A
Authority
JP
Japan
Prior art keywords
memory
memory area
program
area
memory management
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP28253699A
Other languages
Japanese (ja)
Inventor
Hiroshi Oyama
博司 大山
Yasushi Fukaya
安司 深谷
Masato Riyouki
正人 領木
Toru Naoi
徹 直井
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.)
Okuma Corp
Original Assignee
Okuma Corp
Okuma Machinery Works 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 Okuma Corp, Okuma Machinery Works Ltd filed Critical Okuma Corp
Priority to JP28253699A priority Critical patent/JP2001101070A/en
Publication of JP2001101070A publication Critical patent/JP2001101070A/en
Pending legal-status Critical Current

Links

Abstract

(57)【要約】 【課題】 従来のメモリ管理方法及びメモリ管理装置で
は、ガベジコレクションを効率よく行なうことができな
いという問題点があったが、本発明では、リアルタイム
処理の実行に影響を与えることなく、ガベジコレクショ
ンを効率よく行なうことができるメモリ管理方法及びメ
モリ管理装置を提供する。 【解決手段】 中央処理部1が、プログラムメモリ2に
格納されたプログラムを断続的に実行し、ヒープメモリ
4または静的変数記憶部7内の変数からの参照の数を参
照カウント数として、ヒープメモリ4内にメモリ領域に
対応づけて格納し、プログラムの処理が実行終了するご
とに、参照カウント数が0であるメモリ領域を開放する
ガベジコレクション処理を行うメモリ管理方法及びメモ
リ管理装置である。
(57) [Problem] Although a conventional memory management method and memory management device have a problem that garbage collection cannot be performed efficiently, the present invention has an effect on execution of real-time processing. Provided are a memory management method and a memory management device capable of efficiently performing garbage collection without using the memory management method. A central processing unit (1) intermittently executes a program stored in a program memory (2), and uses a heap memory (4) or a variable in a static variable storage unit (7) as a reference count number. A memory management method and a memory management device for performing a garbage collection process of storing a memory area having a reference count of 0 each time the program processing is completed and stored in a memory 4 in association with a memory area. .

Description

【発明の詳細な説明】DETAILED DESCRIPTION OF THE INVENTION

【0001】[0001]

【発明の属する技術分野】本発明は、リアルタイムデー
タを処理するリアルタイムシステムのメモリ管理方法及
びメモリ管理装置に係り、特にガベジコレクションの効
率の改善に関する。
[0001] 1. Field of the Invention [0002] The present invention relates to a memory management method and a memory management device for a real-time system for processing real-time data, and more particularly to improving the efficiency of garbage collection.

【0002】[0002]

【従来の技術】従来のメモリ管理装置について説明す
る。従来より、割り当てられたメモリ領域が使用されな
くなった時に当該メモリ領域を未使用の状態に戻す方
法、すなわちガベジコレクションの方法として種々のも
のが考えられている。例えば「Uniprocessor Garbage C
ollection Techniques」,Paul R.,Wilson,LNCS 637
には、多数のガベジコレクションの方法が紹介されてい
る。
2. Description of the Related Art A conventional memory management device will be described. Conventionally, various methods have been considered as a method of returning an allocated memory area to an unused state when the memory area is no longer used, that is, a garbage collection method. For example, "Uniprocessor Garbage C
ollection Techniques ", Paul R., Wilson, LNCS 637
Introduces a number of garbage collection methods.

【0003】また従来、ハードなリアルタイム処理にお
いて効率を高めたガベジコレクションの方法として、マ
ーク・アンド・スイープ方式のガベジコレクションシス
テムをリアルタイムシステムに応用した、リードバリア
方式がある。ここで、マーク・アンド・スイープ方式の
ガベジコレクションシステムとは、使用されなくなった
メモリ領域を特定するために、予め使用中のメモリ領域
を検出し、ついで使用中のメモリ領域以外を未使用のメ
モリ領域として回収する。また、リードバリア方式によ
るガベジコレクション方法は、ガベジコレクションの処
理とプログラム処理とを並列的に動作させる。これによ
り、単なるマーク・アンド・スイープ方式のように、長
時間に亘ってプログラムの処理が停止することを避ける
ことができ、リアルタイムシステムに適用できる。
[0003] Conventionally, as a garbage collection method for improving the efficiency in hard real-time processing, there is a read barrier method in which a mark-and-sweep garbage collection system is applied to a real-time system. Here, the garbage collection system of the mark-and-sweep method is to detect a memory area that is being used in advance to identify a memory area that is no longer used, and then use an unused memory area other than the used memory area. Collect as a memory area. In the garbage collection method based on the read barrier method, garbage collection processing and program processing are operated in parallel. Thus, it is possible to prevent the processing of the program from being stopped for a long time as in the case of the simple mark-and-sweep method, and the present invention can be applied to a real-time system.

【0004】しかし、この場合にも、基本的にはマーク
・アンド・スイープ方式を採用しているため、ガベジコ
レクションが終了するまで、使用されなくなったメモリ
領域は未使用のメモリ領域として回収されない。このた
め、ガベジコレクションが遅れると、並列的に実行され
ているプログラムの処理中にメモリ領域が不足するおそ
れがある。例えば、仮にガベジコレクションが高々100
ミリ秒で終了することが保証されているとし、プログラ
ム処理は、10ミリ秒の周期で起動されるタスクであると
すると、プログラムで一旦使用され、後に使用されなく
なったメモリ領域は、少なくとも100ミリ秒経過しない
と回収されない。従って、実際に必要となるメモリの少
なくとも、10倍のメモリ領域を用意しなければ、プログ
ラム処理に支障を来してしまう。
However, also in this case, since the mark-and-sweep method is basically used, the memory area that is no longer used is not collected as an unused memory area until the garbage collection is completed. . For this reason, if the garbage collection is delayed, there is a possibility that the memory area becomes insufficient during the processing of the program executed in parallel. For example, if the garbage collection is at most 100
If the program processing is a task that is started at a cycle of 10 milliseconds and the program area is guaranteed to finish in milliseconds, the memory area that is used once by the program and is no longer used will be at least 100 milliseconds. It will not be collected unless seconds elapse. Therefore, unless a memory area at least ten times as large as the actually required memory is prepared, the program processing is hindered.

【0005】さらに、実際にはガベジコレクションを行
なっている間に使用されなくなったメモリ領域の全てが
回収できるとは限らないし、ガベジコレクションが所定
の時間で完了することを保証することは困難であること
から、必要なメモリ量に比べ、多量のメモリを用意しな
くてはならない。
In addition, it is not always possible to recover all the memory areas that are no longer used during garbage collection, and it is difficult to guarantee that garbage collection is completed in a predetermined time. Therefore, it is necessary to prepare a large amount of memory compared to the required amount of memory.

【0006】一方、ガベジコレクションを実現する別の
方法として、参照カウント方式のメモリ管理方法があ
る。参照カウントを利用した従来のメモリ管理方法は、
メモリ領域ごとに参照カウンタを対応づけておき、必要
とされるオブジェクトへの参照開始・参照終了が行われ
る度に当該オブジェクトを格納したメモリ領域の参照カ
ウンタを増減する。この参照カウント方式のガベジコレ
クションの処理は、処理の内容が複雑で、効率が悪い。
そこでこれを改善するために、遅延参照カウント方式が
提案されている(「An Efficient Incremental Automat
ic Garbage Collector」,Peter Deutsch and Daniel
G. Bobrow,Communications of ACM 1976 Vol 19. No.
9)。
On the other hand, as another method for realizing garbage collection, there is a memory management method of a reference counting system. The traditional memory management method using reference counting is
A reference counter is associated with each memory area, and each time reference to a required object is started / referenced, the reference counter of the memory area storing the object is increased or decreased. This reference counting garbage collection process is complicated and inefficient.
In order to improve this, a delayed reference counting method has been proposed (see “An Efficient Incremental Automat
ic Garbage Collector ", Peter Deutsch and Daniel
G. Bobrow, Communications of ACM 1976 Vol 19. No.
9).

【0007】この遅延参照カウント方式では、静的領
域、ヒープ領域に所在する変数への代入時にのみ参照カ
ウントの増減を行うことで、参照カウントの増減を行う
機会を低減するとともに、さらに継続して処理が続けら
れている間にメモリが不足すると、プログラム処理を中
断してスタック領域を走査し、スタック領域に格納され
ている参照用の変数(ポインタ変数)からの参照の数を
調べて参照カウントが「1」以上のメモリ領域と参照カ
ウントが「0」となったメモリ領域とを判別し、参照カ
ウントが「0」となっているメモリ領域を未使用に設定
する。
In this delayed reference counting method, the reference count is increased or decreased only at the time of assignment to a variable located in a static area or a heap area, so that the opportunity of increasing or decreasing the reference count is reduced and further continued. If the memory becomes insufficient while the processing is continued, the program processing is interrupted, the stack area is scanned, the number of references from the reference variables (pointer variables) stored in the stack area is checked, and the reference count is performed. Is determined to be a memory area whose reference count is "0" and a memory area whose reference count is "0", and the memory area whose reference count is "0" is set as unused.

【0008】[0008]

【発明が解決しようとする課題】このように、上記従来
のメモリ管理方法では、リアルタイム処理に影響を与え
ることなくガベジコレクションの処理を効率的に行うこ
とができないという問題点があった。
As described above, the above-mentioned conventional memory management method has a problem that garbage collection cannot be efficiently performed without affecting real-time processing.

【0009】本発明は上記実情に鑑みて為されたもの
で、リアルタイム処理に影響を与えることなくガベジコ
レクションの処理を効率的に実行できるメモリ管理方法
及びメモリ管理装置を提供することを目的とする。
SUMMARY OF THE INVENTION The present invention has been made in view of the above circumstances, and has as its object to provide a memory management method and a memory management device capable of efficiently executing garbage collection processing without affecting real-time processing. I do.

【0010】[0010]

【課題を解決するための手段】上記従来例の問題点を解
決するための請求項1記載の発明は、所定時間で処理終
了するプログラムのために、オブジェクトごとにメモリ
領域を割り当ててメモリを管理するメモリ管理方法であ
って、新規のオブジェクトを生成する際には、前記メモ
リ領域のうち未使用のものを選択し、当該選択した未使
用のメモリ領域にオブジェクトを格納するステップと、
前記メモリ領域に格納されたオブジェクトを参照するポ
インタ変数のうち、ヒープメモリまたは静的変数領域に
格納されているポインタ変数の数を参照カウントとし
て、当該メモリ領域に対応づけて管理するステップと、
前記プログラムが終了した際に各メモリ領域に対応づけ
られた参照カウントを調べ、参照カウントが0である
と、対応するメモリ領域を未使用として設定するステッ
プとを含むことを特徴としている。
According to the first aspect of the present invention, a memory area is allocated to each object for managing a memory for a program which terminates processing in a predetermined time. A memory management method for generating a new object, selecting an unused one of the memory areas and storing the object in the selected unused memory area;
Of pointer variables referring to objects stored in the memory area, managing the number of pointer variables stored in the heap memory or the static variable area as a reference count in association with the memory area;
When the program is completed, a reference count associated with each memory area is checked, and if the reference count is 0, the corresponding memory area is set as unused.

【0011】これにより、プログラムが終了し、スタッ
クに格納された変数が存在しない間に、参照カウントが
0となったメモリ領域を未使用のメモリ領域として設定
でき、リアルタイム処理に影響を与えることなくガベジ
コレクションの処理を効率的に実行できる。
As a result, the memory area whose reference count has become 0 can be set as an unused memory area while the program is terminated and no variable stored in the stack exists, without affecting real-time processing. Garbage collection can be performed efficiently.

【0012】また、参照カウントが0になっているメモ
リ領域を未使用にする前に、当該メモリ領域に格納され
たオブジェクト内部を検索し、当該オブジェクトから参
照されているメモリ領域に対応づけられた参照カウント
をデクリメントすることが好ましい。これにより、参照
カウントを確実に増減させることができる。
Further, before the memory area whose reference count is 0 is unused, the inside of the object stored in the memory area is searched, and the memory area associated with the memory area referenced by the object is searched. Preferably, the reference count is decremented. Thereby, the reference count can be reliably increased or decreased.

【0013】また、上記従来例の問題点を解決するため
の請求項5記載の発明は、所定時間で処理終了するプロ
グラムのために、オブジェクトごとにメモリ領域を割り
当てて、メモリを管理するメモリ管理装置であって、新
規のオブジェクトを生成する際には、前記メモリ領域の
うち未使用のものを選択し、当該選択した未使用のメモ
リ領域にオブジェクトを格納する手段と、前記メモリ領
域に格納されたオブジェクトを指し示すポインタ変数の
うち、ヒープメモリまたは静的変数領域に格納されてい
るポインタ変数の数を参照カウントとして、当該メモリ
領域に対応づけて管理する手段と、前記プログラムが終
了した際に各メモリ領域に対応づけられた参照カウント
を調べ、参照カウントが0であると、対応するメモリ領
域を未使用として設定する手段と、を含むことを特徴と
している。
According to a fifth aspect of the present invention, there is provided a memory management system for allocating a memory area for each object and managing a memory for a program which terminates processing in a predetermined time. An apparatus for generating a new object, selecting an unused one of the memory areas, storing the object in the selected unused memory area, and storing the object in the memory area. Means for managing the number of pointer variables stored in the heap memory or the static variable area as a reference count in association with the memory area, and The reference count associated with the memory area is checked. If the reference count is 0, the corresponding memory area is determined to be unused. It is characterized in that it comprises means for constant, the.

【0014】これにより、プログラムが終了し、スタッ
クに格納された変数が存在しない間に、参照カウントが
0となったメモリ領域を未使用のメモリ領域として設定
でき、リアルタイム処理に影響を与えることなくガベジ
コレクションの処理を効率的に実行できる。
Thus, the memory area whose reference count becomes 0 can be set as an unused memory area while the program is terminated and no variable stored in the stack exists, without affecting the real-time processing. Garbage collection can be performed efficiently.

【0015】さらに、前記プログラムは、割り込み処理
プログラムであることも好適である。これにより、割り
込み処理プログラムが終了したときに確実に未使用のメ
モリを回収でき、かつ割り込み処理に影響を与えること
がない。
Further, it is preferable that the program is an interrupt processing program. As a result, unused memory can be reliably collected when the interrupt processing program ends, and the interrupt processing is not affected.

【0016】さらに、前記プログラムは、定期的に実行
されるプログラムであることも好適である。これによ
り、プログラムが繰り返し起動されても、未使用となっ
たメモリを確実に回収して、メモリの空き容量を圧迫す
ることがなく、かつ定期的に実行されるプログラムの処
理に影響を与えることがない。
Further, it is preferable that the program is a program that is executed periodically. As a result, even if the program is repeatedly started, the unused memory is surely collected, and the free space of the memory is not squeezed, and the processing of the program executed periodically is affected. There is no.

【0017】[0017]

【発明の実施の形態】本発明の実施の形態について図面
を参照しつつ説明する。図1は、本発明の実施の形態に
係るメモリ管理装置の構成ブロック図である。図1に示
すように、本実施の形態のメモリ管理装置は、中央処理
部1と、プログラムメモリ2と、タイマ部3と、ヒープ
メモリ4と、テーブル記憶部5と、スタックメモリ6
と、静的変数記憶部7とから基本的に構成されており、
各部はシステムバスBUSを介して相互に接続されてい
る。
Embodiments of the present invention will be described with reference to the drawings. FIG. 1 is a configuration block diagram of a memory management device according to an embodiment of the present invention. As shown in FIG. 1, the memory management device according to the present embodiment includes a central processing unit 1, a program memory 2, a timer unit 3, a heap memory 4, a table storage unit 5, a stack memory 6,
And a static variable storage unit 7.
Each unit is mutually connected via a system bus BUS.

【0018】プログラムメモリ2は、中央処理部1で処
理されるプログラムが格納されている。タイマ部3は、
一定時間ごとに割り込み信号を出力している。中央処理
部1は、システムバスBUSを介してタイマ部3から一定
時間ごとに割り込み信号の入力を受けて、プログラムメ
モリ2に格納されているプログラムを実行する。尚、こ
の中央処理部1が、請求項にいう、新規のオブジェクト
を生成する際に未使用のメモリ領域を選択してオブジェ
クトを格納する手段と、メモリ領域に参照カウントを対
応づけて管理する手段と、プログラムが終了時に各メモ
リ領域に対応づけられた参照カウントを調べて、参照カ
ウントが0であると、対応するメモリ領域を未使用とし
て設定する手段とに相当する。
The program memory 2 stores a program to be processed by the central processing unit 1. The timer unit 3
An interrupt signal is output at regular intervals. The central processing unit 1 receives an interrupt signal from the timer unit 3 at predetermined time intervals via the system bus BUS, and executes a program stored in the program memory 2. The central processing unit 1 includes a means for selecting an unused memory area when generating a new object and storing the object, and a means for associating a reference count with the memory area. This corresponds to a means for checking the reference count associated with each memory area at the end of the program, and setting the corresponding memory area as unused if the reference count is 0.

【0019】ヒープメモリ4は、中央処理部1がヒープ
領域として利用するメモリを管理する。このヒープメモ
リ4は、複数の領域に分割され、中央処理部1により、
必要に応じて割り当てられる。ヒープメモリ4に格納さ
れているメモリ領域の各々には、当該メモリ領域を参照
するポインタ変数の数(参照カウント;RC)が対応づ
けられている。本発明において特徴的なことは、この参
照カウントは、ヒープメモリ4又は静的変数記憶部7に
格納されているポインタ変数からの参照の数を表してい
ることである。すなわち、スタックメモリ6に格納され
ているポインタ変数からの参照の数はカウントされてい
ない。
The heap memory 4 manages a memory used by the central processing unit 1 as a heap area. The heap memory 4 is divided into a plurality of areas, and the central processing unit 1
Assigned as needed. Each of the memory areas stored in the heap memory 4 is associated with the number of pointer variables (reference count; RC) that refers to the memory area. What is characteristic in the present invention is that the reference count indicates the number of references from the pointer variables stored in the heap memory 4 or the static variable storage unit 7. That is, the number of references from the pointer variables stored in the stack memory 6 is not counted.

【0020】テーブル記憶部5は、テーブル領域を管理
するメモリであり、割り当て可能メモリ領域テーブルAM
Tと、ゼロカウントテーブルZCTと、マルチリファレンス
テーブルMRTと(以下、まとめて「テーブル群」と称す
る)を管理している。ここで、割り当て可能メモリ領域
テーブルAMTは、ヒープメモリ4に格納されている複数
のメモリ領域のうち、未使用のメモリ領域を参照する。
また、ゼロカウントテーブルZCTは、ヒープメモリ4に
格納されている使用中のメモリ領域のうち、参照カウン
トが0であるメモリ領域を参照する。さらに、マルチリ
ファレンステーブルMRTは、ヒープメモリ4に格納され
ている使用中のメモリ領域のうち、参照カウントが1以
上のものを参照する。スタックメモリ6は、ローカル変
数等のプログラムを処理している間でのみ利用される変
数を格納する。静的変数記憶部7は、静的な変数を格納
する。ここで静的とは、プログラム終了後もその内容が
保持されることを意味する。
The table storage unit 5 is a memory for managing a table area, and includes an allocatable memory area table AM.
T, a zero count table ZCT, and a multi-reference table MRT (hereinafter collectively referred to as a “table group”). Here, the assignable memory area table AMT refers to an unused memory area among a plurality of memory areas stored in the heap memory 4.
Further, the zero count table ZCT refers to a memory area having a reference count of 0 among the memory areas in use stored in the heap memory 4. Furthermore, the multi-reference table MRT refers to a memory area in use stored in the heap memory 4 and having a reference count of 1 or more. The stack memory 6 stores variables used only during processing of the program, such as local variables. The static variable storage 7 stores static variables. Here, “static” means that the contents are retained even after the program ends.

【0021】ここで、中央処理部1の処理の内容につい
て具体的に図2〜図13を参照しつつ説明する。図2〜
9は、中央処理部1がプログラムを処理している間のメ
モリの内容を表す説明図であり、図10〜図13は、中
央処理部1の処理を表すフローチャート図である。
Here, the contents of the processing of the central processing unit 1 will be specifically described with reference to FIGS. Figure 2
9 is an explanatory diagram showing the contents of the memory while the central processing unit 1 is processing the program, and FIGS. 10 to 13 are flowcharts showing the processing of the central processing unit 1.

【0022】まず、プログラムが一度も実行されていな
いときのテーブル記憶部5と、ヒープメモリ4と、スタ
ックメモリ6と、静的変数記憶部7のそれぞれの内容
は、図2に示すようになっている。図2に示すように、
テーブル記憶部5の割り当て可能メモリテーブルAMT
は、ヒープメモリ4に格納されている割り当て可能なメ
モリ(未使用の領域)をすべて指し示して(参照して)
いる。図2に示したプログラムが一度も実行されていな
い状態では、すべてのメモリ領域MEM1〜MEMnが未使用で
あるため、割り当て可能メモリテーブルAMTは、すべて
のメモリ領域を参照している。図2では、各メモリ領域
は初期化されていないので、参照カウントRCは、不定
値(「?」として図示している)となっており、従って
ゼロカウントテーブルZCTと、マルチリファレンステー
ブルMRTとには、何も登録されていない。
First, the contents of the table storage unit 5, the heap memory 4, the stack memory 6, and the static variable storage unit 7 when the program has never been executed are as shown in FIG. ing. As shown in FIG.
Allocatable memory table AMT of table storage unit 5
Indicates (refers to) all the allocable memory (unused area) stored in the heap memory 4.
I have. In a state where the program shown in FIG. 2 has never been executed, all the memory areas MEM1 to MEMn are unused, so the allocatable memory table AMT refers to all the memory areas. In FIG. 2, since each memory area has not been initialized, the reference count RC has an indefinite value (shown as “?”). Therefore, the zero-count table ZCT and the multi-reference table MRT have different values. Has nothing registered.

【0023】中央処理部1は、特定のプログラムを断続
的に実行しつつリアルタイムの処理を行っており、この
プログラム中で、「メモリ領域を割り当てる」処理(割
り当て処理)と、「変数にメモリ領域への参照を格納す
る」処理(ポインタ設定処理)と、「変数からメモリ領
域への参照を解消する」処理(ポインタ解放処理)とを
基本的に行っている。また、中央処理部1は、「メモリ
領域を回収する」処理(ガベジコレクション処理)を行
う。
The central processing unit 1 performs real-time processing while intermittently executing a specific program. In this program, a “memory area allocation” process (allocation process) and a “memory area Basically, a process of storing a reference to a pointer (pointer setting process) and a process of releasing a reference from a variable to a memory area (pointer release process) are performed. In addition, the central processing unit 1 performs a process of “collecting a memory area” (a garbage collection process).

【0024】以下、中央処理部1の割り当て処理につい
て図10を参照しつつ説明する。中央処理部1は、割り
当て処理を開始すると、割り当て可能メモリテーブルAM
Tから未使用のメモリ領域を検索して選択し(S1
1)、選択したメモリ領域を割り当て可能メモリテーブ
ルAMTから取り除いて(S12)、選択したメモリ領域
の参照カウントRCを「0」に初期化する(S13)。
そして、中央処理部1は、選択したメモリ領域をゼロカ
ウントテーブルZCTに登録し(S14)、処理を終了す
る。そして、ゼロカウントテーブルZCTからは、割り当
てられ、初期化されたメモリ領域が参照されているよう
になる。
Hereinafter, the assignment processing of the central processing unit 1 will be described with reference to FIG. When starting the allocation processing, the central processing unit 1 allocates the assignable memory table AM
Search and select an unused memory area from T (S1
1) The selected memory area is removed from the assignable memory table AMT (S12), and the reference count RC of the selected memory area is initialized to “0” (S13).
Then, the central processing unit 1 registers the selected memory area in the zero count table ZCT (S14), and ends the processing. Then, the allocated and initialized memory area is referred to from the zero count table ZCT.

【0025】また、中央処理部1のポインタ設定処理に
ついて図11を参照しつつ説明する。以下の説明におい
て、メモリ領域Aを変数Xに代入するとは、メモリ領域
Aを参照するポインタ(メモリアドレスや参照のための
識別子(ID))を変数Xに設定することをいう。中央
処理部1は、ポインタ設定処理が開始されると、設定し
ようとしている変数Xがヒープメモリ4又は静的変数記
憶部7に格納されているものであるか否かを判断し(S
21)、変数Xがヒープメモリ4又は静的変数記憶部7
に格納されていれば(Yesならば)、設定の対象とな
るメモリ領域Aの参照カウントRCが初期値「0」であ
るか否かを判断する(S22)。ここで、設定の対象と
なるメモリ領域Aの参照カウントRCが初期値「0」に
なっていれば(Yesならば)、メモリ領域をゼロカウ
ントテーブルZCTから取り除いて(S23)、マルチリ
ファレンステーブルMRTに登録する(S24)。そし
て、当該メモリ領域Aの参照カウントRCをインクリメ
ントし(S25)、メモリ領域Aへのポインタを変数X
に格納して設定し(S26)、処理を終了する。また、
処理S22において、設定の対象となるメモリ領域Aの
参照カウントRCが初期値「0」でなければ(Noなら
ば)、処理S25に移行して処理を続ける。さらに、処
理S21において、設定しようとしている変数Xがヒー
プメモリ4又は静的変数記憶部7に格納されているもの
でなければ(Noならば)、処理S26に移行して処理
を行う。
The pointer setting process of the central processing unit 1 will be described with reference to FIG. In the following description, substituting the memory area A for the variable X means setting a pointer (a memory address or an identifier (ID) for reference) referring to the memory area A to the variable X. When the pointer setting process is started, the central processing unit 1 determines whether or not the variable X to be set is stored in the heap memory 4 or the static variable storage unit 7 (S
21) The variable X is the heap memory 4 or the static variable storage unit 7
(If Yes), it is determined whether or not the reference count RC of the memory area A to be set is the initial value “0” (S22). Here, if the reference count RC of the memory area A to be set is the initial value “0” (if Yes), the memory area is removed from the zero count table ZCT (S23), and the multi-reference table MRT (S24). Then, the reference count RC of the memory area A is incremented (S25), and the pointer to the memory area A is set to the variable X
And set (S26), and the process ends. Also,
In the process S22, if the reference count RC of the memory area A to be set is not the initial value “0” (if No), the process proceeds to the process S25 to continue the process. Further, in step S21, if the variable X to be set is not stored in the heap memory 4 or the static variable storage unit 7 (if No), the process proceeds to step S26 to perform the processing.

【0026】さらに、中央処理部1のポインタ解放処理
について図12を参照しつつ説明する。中央処理部1
は、ポインタ解放処理が開始されると、解放しようとす
る変数Xがヒープメモリ4又は静的変数記憶部7に格納
されているものであるか否かを判断し(S31)、変数
Xがヒープメモリ4又は静的変数記憶部7に格納されて
いれば(Yesならば)、変数Xが参照していたメモリ
領域Aの参照カウントRCをデクリメントする(S3
2)。そして、中央処理部1は、当該メモリ領域Aの参
照カウントが初期値「0」に等しくなったか否か、すな
わち、当該メモリ領域Aを参照するポインタ変数がなく
なったか否かを判断し(S33)、当該メモリ領域Aを
参照するポインタ変数がなくなり、初期値「0」に等し
くなった場合には(Yesならば)、当該メモリ領域A
をマルチリファレンステーブルMRTから取り除いて(S
34)、メモリ領域をゼロカウントテーブルZCTに登録
し(S35)、処理を終了する。また、処理S33にお
いて、当該メモリ領域Aを参照するポインタ変数がヒー
プメモリ4または静的変数記憶部7にまだ残っており、
メモリ領域Aの参照カウントRCが初期値「0」に等し
くなければ(Noならば)、そのまま処理を終了する。
さらに、処理S31において、変数Xがヒープメモリ4
又は静的変数記憶部7に格納されているものでなければ
(Noであれば)、そのまま処理を終了する。
Further, pointer release processing of the central processing unit 1 will be described with reference to FIG. Central processing unit 1
When the pointer release process is started, it is determined whether or not the variable X to be released is stored in the heap memory 4 or the static variable storage unit 7 (S31). If it is stored in the memory 4 or the static variable storage unit 7 (Yes), the reference count RC of the memory area A referred to by the variable X is decremented (S3).
2). Then, the central processing unit 1 determines whether or not the reference count of the memory area A has become equal to the initial value “0”, that is, whether or not there is no pointer variable that refers to the memory area A (S33). If there is no pointer variable referring to the memory area A and it becomes equal to the initial value “0” (if Yes), the memory area A
From the multi-reference table MRT (S
34), the memory area is registered in the zero count table ZCT (S35), and the process ends. In the process S33, the pointer variable referring to the memory area A still remains in the heap memory 4 or the static variable storage unit 7,
If the reference count RC of the memory area A is not equal to the initial value “0” (if No), the processing is terminated.
Further, in the process S31, the variable X is stored in the heap memory 4
Otherwise, if it is not stored in the static variable storage unit 7 (if No), the processing is terminated as it is.

【0027】さらに、中央処理部1のガベジコレクショ
ン処理について図13を参照しつつ説明する。中央処理
部1は、ガベジコレクション処理を開始すると、まず、
ゼロカウントテーブルZCTを走査し、ゼロカウントテー
ブルZCTに登録されているすべてのメモリ領域MEMiにつ
いて以下に説明する処理S42以降の処理が完了したか
否かを判断し(S41)、処理が完了していなければ
(Noならば)、特定のメモリ領域MEMi内にあるすべて
の変数HViについて、処理S43以降の処理が完了して
いるか否かを判断する(S42)。そして、処理が完了
していなければ(Noであれば)、特定の変数HViが他
のメモリ領域を参照しているか否かを判断し(S4
3)、参照していれば(Yesならば)、既に説明した
ポインタ解放処理を行って、変数HViからメモリ領域X
の参照を解消し(S44)、処理S41に戻って処理を
続ける。また、処理S43において、変数HViが他のメ
モリ領域を参照していなければ(Noであれば)、処理
S41に戻って処理を続ける。さらに、処理S42にお
いて、メモリ領域MEMi内にある変数HViについて処理が
完了していれば(Yesならば)、処理S41に戻って
処理を続ける。さらに、処理S41において、ゼロカウ
ントテーブルZCTに登録されているすべてのメモリ領域
について処理が終了していれば(Yesならば)、その
まま処理を終了する。
The garbage collection process of the central processing unit 1 will be described with reference to FIG. When starting the garbage collection process, the central processing unit 1 first
The zero count table ZCT is scanned, and it is determined whether or not the processing of step S42 and subsequent steps described below has been completed for all the memory areas MEMi registered in the zero count table ZCT (S41), and the processing has been completed. If not (No), it is determined whether or not the processing after step S43 has been completed for all variables HVi in the specific memory area MEMi (S42). If the processing is not completed (if No), it is determined whether or not the specific variable HVi refers to another memory area (S4).
3) If it is referred to (if Yes), the pointer release processing described above is performed, and the memory area X is obtained from the variable HVi.
Is canceled (S44), and the process returns to step S41 to continue the process. If the variable HVi does not refer to another memory area in the process S43 (if No), the process returns to the process S41 to continue the process. Further, in step S42, if the process has been completed for the variable HVi in the memory area MEMi (if Yes), the process returns to step S41 to continue the process. Further, in step S41, if the processing has been completed for all the memory areas registered in the zero count table ZCT (if Yes), the processing ends as it is.

【0028】以下、中央処理部1において、各処理が行
われたときのメモリの内容の変化について説明する。ま
ず、図2の状態にある時に、中央処理部1がヒープメモ
リ4にメモリ領域MEM1を割り当てて、スタックメモリ6
上に所在するローカル変数LCV-Xに対し、メモリ領域MEM
1へのポインタが設定されたときについて説明する。図
3は、スタックメモリ6上のローカル変数LCV-Xにポイ
ンタが設定された後の状態を表す。図2から図3の状態
への遷移は、領域割り当て処理と、ポインタ設定処理と
によりなされる。まず領域割り当て処理により、ヒープ
メモリ4上に割り当て可能なメモリ領域が検索される。
図2では、例えばメモリ領域MEM1が未使用であり、割り
当てが可能なので、MEM1が選択され、所定の処理の後、
MEM1が初期化される。この結果、メモリ領域MEM1は割り
当て可能メモリテーブルAMTから取り除かれ、ゼロカウ
ントテーブルZCTに登録される。そして、ポインタ設定
処理により、ポインタが変数LCV-Xに設定されるが、こ
の代入先の変数 LCV-X はローカル変数であり、スタッ
クメモリ6に格納されているので、メモリ領域MEM1に対
応する参照カウントRCはインクリメントされず、メモ
リ領域LCV-Xを参照するポインタが、ローカル変数LCV-X
に記憶されるのみである。
Hereinafter, changes in the contents of the memory when each processing is performed in the central processing unit 1 will be described. First, when in the state of FIG. 2, the central processing unit 1 allocates the memory area MEM1 to the heap memory 4 and
For the local variable LCV-X located above, the memory area MEM
The case where the pointer to 1 is set will be described. FIG. 3 shows a state after the pointer is set to the local variable LCV-X on the stack memory 6. The transition from the state shown in FIG. 2 to the state shown in FIG. 3 is performed by an area allocation process and a pointer setting process. First, a memory area that can be allocated on the heap memory 4 is searched by the area allocation processing.
In FIG. 2, for example, since the memory area MEM1 is unused and can be allocated, MEM1 is selected, and after predetermined processing,
MEM1 is initialized. As a result, the memory area MEM1 is removed from the allocatable memory table AMT and registered in the zero count table ZCT. Then, the pointer is set to the variable LCV-X by the pointer setting process. Since the variable LCV-X at the substitution destination is a local variable and is stored in the stack memory 6, the pointer corresponding to the memory area MEM1 is referred to. The count RC is not incremented, and the pointer referring to the memory area LCV-X is set to the local variable LCV-X
It is only stored in

【0029】さらに、図3の状態にある時に、メモリ領
域MEM2が割り当てられて静的変数STV-Aへメモリ領域MEM
2へのポインタが代入される場合について説明する。静
的変数STV-Aへの代入後の状態を表すのが図4である。
図3から図4への遷移、すなわちメモリ領域MEM2の静的
変数STV-Aへの代入は、領域割り当て処理とポインタ設
定処理とにより達成される。まず領域割り当て処理によ
り、割り当て可能な未使用のメモリ領域MEM2が割り当て
られる。そして、このメモリ領域MEM2は割り当て可能メ
モリテーブルAMTからは取り除かれ、ゼロカウントテー
ブルZCTに登録される。続いて、ポインタ設定処理によ
り代入が行われるが、この場合、代入先の変数STV-Aは
静的変数記憶部7に格納されている静的変数であり、か
つ割り当て直後のメモリ領域の参照カウントRCは初期
値に等しいから、メモリ領域MEM2はゼロカウントテーブ
ルZCTから取り除かれ、マルチリファレンステーブルMRT
に登録される。更にメモリ領域MEM2の参照カウントRC
はインクリメントされて「1」となる。
Further, in the state of FIG. 3, the memory area MEM2 is allocated and the memory area MEM2 is stored in the static variable STV-A.
The case where the pointer to 2 is assigned will be described. FIG. 4 shows a state after the assignment to the static variable STV-A.
The transition from FIG. 3 to FIG. 4, that is, the assignment of the memory area MEM2 to the static variable STV-A is achieved by the area allocation processing and the pointer setting processing. First, an unused memory area MEM2 that can be allocated is allocated by the area allocation processing. Then, this memory area MEM2 is removed from the allocatable memory table AMT and registered in the zero count table ZCT. Subsequently, the assignment is performed by the pointer setting process. In this case, the assignment destination variable STV-A is a static variable stored in the static variable storage unit 7 and the reference count of the memory area immediately after the assignment. Since RC is equal to the initial value, the memory area MEM2 is removed from the zero count table ZCT and the multi-reference table MRT
Registered in. Further, reference count RC of memory area MEM2
Is incremented to “1”.

【0030】さらに、図4の状態にある時、静的変数ST
V-Aが参照するメモリ領域MEM2がメモリ領域MEM1内のオ
ブジェクトに所在する変数HV1からも参照される場合に
ついて説明する。この変数HV1にメモリ領域MEM1へのポ
インタを代入した後の状態を表すのが、図5である。こ
れは、変数HV1に対するポインタ設定処理により達成さ
れる。この場合、変数HV1はメモリ領域MEM1内のオブジ
ェクトに存在している、即ちヒープメモリ4に所在する
ため、メモリ領域MEM2の参照カウントRCがインクリメ
ントされ、RCは「2」となり、メモリ領域MEM2を識別
するポインタが変数HV1に記憶される。
Further, when in the state of FIG. 4, the static variable ST
A case where the memory area MEM2 referred to by the VA is also referred to by the variable HV1 located in the object in the memory area MEM1 will be described. FIG. 5 shows a state after the pointer to the memory area MEM1 is assigned to the variable HV1. This is achieved by a pointer setting process for the variable HV1. In this case, since the variable HV1 exists in the object in the memory area MEM1, that is, is located in the heap memory 4, the reference count RC of the memory area MEM2 is incremented, and RC becomes “2”, and the memory area MEM2 is identified. Is stored in the variable HV1.

【0031】さらに図5の状態にある時に、静的変数ST
V-Aがメモリ領域MEM2を参照しなくなった場合について
説明する。静的変数STV-Aがメモリ領域MEM2を参照しな
くなった後の状態を表すのが、図6である。図5から図
6への遷移、すなわちメモリ領域MEM2が静的変数STV-A
から参照されなくなるようにするのは、静的変数STV-A
に対するポインタ解放処理により実現される。この場合
は、メモリ領域MEM2の参照カウントRCをデクリメント
するが、デクリメントした後の参照カウントRCの値は
初期値「0」にはならないので、そのままポインタ解放
処理を終了する。
Further, when in the state of FIG. 5, the static variable ST
A case where the VA no longer references the memory area MEM2 will be described. FIG. 6 shows a state after the static variable STV-A no longer references the memory area MEM2. The transition from FIG. 5 to FIG. 6, that is, the memory area MEM2 is a static variable STV-A
To be no longer referenced by the static variable STV-A
This is realized by pointer release processing for. In this case, the reference count RC of the memory area MEM2 is decremented. However, since the value of the decremented reference count RC does not become the initial value “0”, the pointer release processing ends as it is.

【0032】さらに、メモリの内容が図7の状態にある
ときにプログラムが終了した場合について説明する。図
7に示す状態では、第1のメモリ領域MEM1がスタックメ
モリ6に格納されている変数LCV-Xから参照され、第2
のメモリ領域MEM2が第1のメモリ領域MEM1内のオブジェ
クトに存在する変数HV1から参照され、第3のメモリ領
域MEM3が静的変数記憶部7内の変数STV-Bから参照され
ている。従って、第1のメモリ領域MEM1は、初期化はさ
れているが、ヒープメモリ4(すなわち他のメモリ領域
のオブジェクト)又は静的変数記憶部7から参照されて
いないので、その参照カウントRCの値は初期値「0」
のままであり、ゼロカウントテーブルZCTから参照され
るようになっている。一方、第2のメモリ領域MEM2は、
ヒープメモリ4内の変数から参照されているから、その
参照カウントRCの値は「1」となっており、マルチリ
ファレンステーブルMRTから参照されている。同様に、
第3のメモリ領域MEM3は、静的変数記憶部7内の変数か
ら参照されているために、その参照カウントRCの値は
「1」になっており、マルチリファレンステーブルMRT
から参照されている。
Next, the case where the program ends when the contents of the memory are in the state shown in FIG. 7 will be described. In the state shown in FIG. 7, the first memory area MEM1 is referred to from the variable LCV-X stored in the stack
Is referred to by the variable HV1 existing in the object in the first memory area MEM1, and the third memory area MEM3 is referred to by the variable STV-B in the static variable storage unit 7. Therefore, the first memory area MEM1 has been initialized, but is not referred to from the heap memory 4 (that is, an object of another memory area) or the static variable storage unit 7, so that the value of the reference count RC is Is the initial value "0"
And it is referred from the zero count table ZCT. On the other hand, the second memory area MEM2 is
The value of the reference count RC is “1” because it is referenced from a variable in the heap memory 4 and is referenced from the multi-reference table MRT. Similarly,
Since the third memory area MEM3 is referenced from a variable in the static variable storage unit 7, the value of the reference count RC is “1”, and the multi-reference table MRT
Is referenced from.

【0033】一般に、プログラムが終了すると、スタッ
クメモリ6に格納されている変数は、すべてクリアされ
るので、プログラム終了後のメモリの内容は、図8に示
すように、ローカル変数LCV-Xが消滅しているようにな
る。尚、プログラム終了の際に、スタックメモリ6内の
変数LCV-Xから第1のメモリ領域MEM1への参照を解消す
る操作は、ポインタ解放処理によって行われるが、この
場合、変数LCV-Xはスタックメモリ6にあるため、テー
ブルの内容に変化は生じない。
Generally, when the program ends, all the variables stored in the stack memory 6 are cleared. Therefore, as shown in FIG. 8, the contents of the memory after the program ends are such that the local variable LCV-X disappears. It will be like that. At the end of the program, the operation of releasing the reference from the variable LCV-X in the stack memory 6 to the first memory area MEM1 is performed by pointer release processing. In this case, the variable LCV-X Since it is in the memory 6, there is no change in the contents of the table.

【0034】さらに、図9は、図8の状態にあるときに
メモリ回収が行われた後の状態を示す説明図である。図
8から図9の遷移は、ガベジコレクション処理によりメ
モリ領域が回収されて、達成される。すなわち、始めに
ゼロカウントテーブルZCTに登録された第1のメモリ領
域MEM1が選択され、調べられるが、第1のメモリ領域ME
M1は既にスタック以外のメモリに格納された変数からは
参照されておらず、未使用であるため、回収可能なメモ
リ領域である。しかし、この第1のメモリ領域MEM1を解
放して未使用とすると、第2のメモリ領域MEM2を指すポ
インタ変数も消滅するにも関わらず、第2のメモリ領域
MEM2に対応する参照カウントRCを調整する処理を行わ
ないことになる。そこでこの第1のメモリ領域MEM1が回
収される前に、第1のメモリ領域MEM1に所在する変数か
ら他のメモリ領域への参照をすべて解消する必要があ
る。この場合は変数HV1からメモリ領域MEM2への参照を
解消する必要がある。
FIG. 9 is an explanatory diagram showing a state after memory recovery is performed in the state of FIG. The transition from FIG. 8 to FIG. 9 is achieved by collecting the memory area by the garbage collection process. That is, first, the first memory area MEM1 registered in the zero count table ZCT is selected and examined.
M1 is a memory area that can be collected because it is not referenced from variables already stored in memory other than the stack and is unused. However, if the first memory area MEM1 is released and unused, the second memory area MEM2 is deleted even though the pointer variable pointing to the second memory area MEM2 also disappears.
The process of adjusting the reference count RC corresponding to MEM2 is not performed. Therefore, before the first memory area MEM1 is collected, it is necessary to cancel all references from variables located in the first memory area MEM1 to other memory areas. In this case, it is necessary to cancel the reference from the variable HV1 to the memory area MEM2.

【0035】そして、この変数HV1を解放する処理を行
う結果、第2のメモリ領域MEM2はマルチリファレンステ
ーブルMRTから取り除かれて、ゼロカウントテーブルZCT
へ登録される。そして、第2のメモリ領域MEM2も回収の
対象となる。
Then, as a result of performing the process of releasing the variable HV1, the second memory area MEM2 is removed from the multi-reference table MRT and the zero count table ZCT
Registered to. Then, the second memory area MEM2 is also a collection target.

【0036】このようにして、第1のメモリ領域MEM1
と、第2のメモリ領域MEM2とが回収されて、ゼロカウン
トテーブルZCTからも取り除かれ、未使用のメモリ領域
として、割り当て可能メモリテーブルAMTに登録され
る。ここで、唯一静的変数STV-Bから参照される第3の
メモリ領域MEM3がマルチリファレンステーブルMRTに登
録された状態で残されているが、他のメモリ領域はすべ
て回収されて、未使用のメモリ領域として、割り当て可
能メモリ領域AMTに登録されているようになる。なお、
回収されたメモリ領域MEMiにおいては、参照カウントが
初期値と等しくなっており、次回割り当て時に初期化す
る必要はない。
Thus, the first memory area MEM1
Then, the second memory area MEM2 is collected, removed from the zero count table ZCT, and registered in the allocatable memory table AMT as an unused memory area. Here, only the third memory area MEM3 referred to by the static variable STV-B remains registered in the multi-reference table MRT, but all other memory areas are collected and unused. The memory area is registered in the allocatable memory area AMT. In addition,
In the recovered memory area MEMi, the reference count is equal to the initial value, and does not need to be initialized at the next allocation.

【0037】次に、本実施の形態のメモリ管理装置の動
作について、より具体的に、シミュレーションを行うプ
ログラムが中央処理部1で実行されている場合を例とし
て説明する。尚、以下の説明では、図14に示すよう
に、システムバスBUSを介してビデオインターフェース
8が接続されている場合を例として説明する。このビデ
オインターフェース8は、ビデオメモリ11を含み、シ
ステムバスBUSを介して中央処理部1に対し、垂直同期
信号を割り込み信号として出力する。また、ここでは、
中央処理部1は、プログラムメモリ2に格納されたプロ
グラムに従って、この割り込み信号の入力を受けると、
ビデオメモリ11に書き込むべきデータを生成し、ビデ
オメモリ11に書き込む処理を行う。尚、垂直同期信号
に同期してビデオインタフェース8内のビデオメモリ1
1の内容をシミュレーションの経過に併せて更新し、よ
りリアルな動画画像の表示を可能とするために、中央処
理部1は、画面の走査が行われている間に次のフレーム
で表示すべき更新データの作成を完了し、垂直帰線期間
内に更新データをビデオメモリ11に書き込む必要があ
る。すなわち、ここで中央処理部1は、画面の走査を開
始するとともに処理開始し、走査の終了時までに処理を
完了する第1の処理と、割り込み信号としての垂直同期
信号の入力を受けて処理開始し、垂直帰線期間内に処理
終了する第2の処理とを交互に断続的に行うのである。
尚、この第1,第2の処理において、オブジェクトを生
成し、ポインタを設定、解放する処理では、既に説明し
た領域割り当て処理と、ポインタ設定処理と、ポインタ
解放処理とが用いられているとする。
Next, the operation of the memory management device according to the present embodiment will be described more specifically by taking a case where a program for performing a simulation is executed by the central processing unit 1 as an example. In the following description, a case where the video interface 8 is connected via a system bus BUS as shown in FIG. 14 will be described as an example. The video interface 8 includes a video memory 11 and outputs a vertical synchronization signal as an interrupt signal to the central processing unit 1 via a system bus BUS. Also, here
When receiving the interrupt signal according to the program stored in the program memory 2, the central processing unit 1
Data to be written to the video memory 11 is generated, and a process of writing to the video memory 11 is performed. The video memory 1 in the video interface 8 is synchronized with the vertical synchronizing signal.
The central processing unit 1 should display the next frame while the screen is being scanned, in order to update the content of No. 1 as the simulation progresses and to display a more realistic moving image. It is necessary to complete the creation of the update data and write the update data to the video memory 11 within the vertical blanking period. That is, here, the central processing unit 1 starts the screen scanning and starts the processing, and completes the processing by the end of the scanning, and receives the input of the vertical synchronization signal as the interrupt signal. The second process, which starts and ends the process within the vertical flyback period, is performed alternately and intermittently.
In the first and second processes, in the process of generating an object and setting and releasing a pointer, it is assumed that the area allocation process, the pointer setting process, and the pointer releasing process described above are used. .

【0038】そして、中央処理部1は、第1,第2の処
理が終了するごとに、上述のガベジコレクション処理を
行う。これにより、ビデオメモリの更新データを作成す
る第1の処理においては、割り込み信号の入力により処
理の完了を検知して、不要となったメモリ領域を回収す
ることができる。また、必ずしも垂直同期信号とは限ら
ず、例えば第2の処理の終了を検知するには、第2の処
理が定期的に実行される処理であることに着目して、タ
イマ部3に第2の処理の実行完了に同期する割り込み信
号を出力させ、このタイマ部3から発行される割込みに
従って、中央処理部1がガベジコレクション処理を行う
ようにしても構わない。
Then, the central processing unit 1 performs the above-mentioned garbage collection process every time the first and second processes are completed. Thus, in the first process for creating the update data of the video memory, the completion of the process is detected by the input of the interrupt signal, and the unnecessary memory area can be collected. In addition, the timer unit 3 is not necessarily a vertical synchronization signal. For example, in order to detect the end of the second process, the timer unit 3 needs to pay attention to the fact that the second process is a process that is periodically executed. The CPU 3 may output an interrupt signal synchronized with the completion of the execution of the process, and the central processing unit 1 may perform the garbage collection process in accordance with the interrupt issued from the timer unit 3.

【0039】さらに、割込み信号によりプログラムを起
動させるように構成された装置であれば、シミュレーシ
ョン装置以外にも、例えば数値制御装置等の関数発生処
理のように一定期間毎に数値演算を行うものにも応用で
きる。
Further, if the apparatus is configured to start a program by an interrupt signal, it is not limited to a simulation apparatus, but may be an apparatus that performs a numerical operation at regular intervals, such as a function generating process of a numerical control device or the like. Can also be applied.

【0040】ここで割込みの周期は必ずしも一定でなく
てもよく、例えば通信パケット等のように不定期に到着
したものを一定時間内に割込みプログラムによって処理
し、次のパケットの到着に備えるようにしてもよい。
Here, the cycle of the interrupt need not always be constant. For example, a packet that arrives irregularly, such as a communication packet, is processed by an interrupt program within a fixed time so as to prepare for the arrival of the next packet. You may.

【0041】さらに、必ずしも割込み信号によりプログ
ラムが起動されなくてもよく、例えば一定時間毎にプロ
グラムが起動されるようにしてもよい。この場合には図
15に示すように、中央処理部1は、一定時間経過する
まで、タイミングを待ち(S51)、一定期間内に終わ
るように作成されたプログラムを起動し(S52)、こ
のプログラムの終了後にガベジコレクション処理を行っ
て、メモリを回収(S53)すればよい。
Further, the program does not necessarily have to be started by an interrupt signal, but may be started at regular intervals, for example. In this case, as shown in FIG. 15, the central processing unit 1 waits for a timing until a certain time has elapsed (S51), starts a program created so as to end within a certain period (S52), and executes this program. Garbage collection processing may be performed after the end of the processing, and the memory may be collected (S53).

【0042】ここで一定時間経過するまでタイミングを
待つ処理S51は、垂直同期信号やタイマ部3の値を監
視するようなポーリングと呼ばれる方法を用いることも
できるし、オペレーティングシステムが提供するタイミ
ングを図るシステムコールにより実現することもでき
る。
Here, the process S51 of waiting for timing until a predetermined time elapses can use a method called polling for monitoring the value of the vertical synchronizing signal or the timer unit 3, or the timing provided by the operating system. It can also be realized by a system call.

【0043】このように、本発明において特徴的なこと
は、例えばリアルタイム処理では、プログラムが比較的
短時間の一定の時間で完了し、その際にスタックメモリ
6に格納されている変数がすべて消去され、ヒープメモ
リ4内のメモリ領域がスタックメモリ6から参照される
ことがあり得ないことに着目して、プログラムの終了の
タイミングでガベジコレクションの処理を行うことであ
る。これにより、ガベジコレクションの際にスタックメ
モリ6内を検索する必要がなくなり、かつ、スタックメ
モリ6からの参照の数を参照カウントとしてカウントす
る必要がなくなる。従って、特別なハードウェアを用い
ることなくガベジコレクションを効率よく行なうことが
でき、特にゴミとなった(未使用となった)メモリ領域
内にある変数から参照されるメモリ領域の解放がプログ
ラムの完了後に行われるために、ガベジコレクション処
理よりも本来のプログラムの実行が優先され、本来のプ
ログラムの実行に影響を与えることがない。また、プロ
グラムが完了すると同時に直ちにメモリが回収されるた
め、プログラムが1回実行されるのに必要となるメモリ
領域を用意すればよく、必要となるメモリ容量を低減で
きる。
As described above, a characteristic of the present invention is that, for example, in real-time processing, a program is completed in a relatively short period of time and all variables stored in the stack memory 6 are erased. Then, paying attention to the fact that the memory area in the heap memory 4 cannot be referred to from the stack memory 6, the garbage collection process is performed at the timing of the end of the program. This eliminates the need to search the stack memory 6 at the time of garbage collection, and eliminates the need to count the number of references from the stack memory 6 as a reference count. Therefore, garbage collection can be performed efficiently without using special hardware. In particular, the release of a memory area referenced by a variable in a garbage (unused) memory area can be performed by a program. Since the processing is performed after the completion, the execution of the original program is prioritized over the garbage collection processing, and the execution of the original program is not affected. Further, since the memory is collected immediately upon completion of the program, a memory area required for executing the program once may be prepared, and the required memory capacity can be reduced.

【0044】[0044]

【発明の効果】本発明によれば、プログラムの終了のタ
イミングでガベジコレクションの処理を行うことで、リ
アルタイム処理の実行に影響を与えることなく、ガベジ
コレクションを効率よく行なうことができる。
According to the present invention, garbage collection can be performed efficiently without affecting the execution of real-time processing by performing garbage collection at the end of the program.

【0045】また、プログラムが完了すると同時に直ち
にメモリが回収されるため、プログラムが1回実行され
るのに必要となるメモリ領域を用意すればよく、必要と
なるメモリ容量を低減できる。
Further, since the memory is recovered immediately upon completion of the program, a memory area required for executing the program once may be prepared, and the required memory capacity can be reduced.

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

【図1】 本発明の実施の形態に係るメモリ管理装置の
構成ブロック図である。
FIG. 1 is a configuration block diagram of a memory management device according to an embodiment of the present invention.

【図2】 中央処理部1がプログラムを処理している間
のメモリの内容を表す説明図である。
FIG. 2 is an explanatory diagram showing contents of a memory while a central processing unit 1 is processing a program.

【図3】 中央処理部1がプログラムを処理している間
のメモリの内容を表す説明図である。
FIG. 3 is an explanatory diagram showing the contents of a memory while a central processing unit 1 is processing a program.

【図4】 中央処理部1がプログラムを処理している間
のメモリの内容を表す説明図である。
FIG. 4 is an explanatory diagram showing the contents of a memory while the central processing unit 1 is processing a program.

【図5】 中央処理部1がプログラムを処理している間
のメモリの内容を表す説明図である。
FIG. 5 is an explanatory diagram showing the contents of a memory while the central processing unit 1 is processing a program.

【図6】 中央処理部1がプログラムを処理している間
のメモリの内容を表す説明図である。
FIG. 6 is an explanatory diagram showing the contents of a memory while the central processing unit 1 is processing a program.

【図7】 中央処理部1がプログラムを処理している間
のメモリの内容を表す説明図である。
FIG. 7 is an explanatory diagram showing the contents of a memory while the central processing unit 1 is processing a program.

【図8】 中央処理部1がプログラムを処理している間
のメモリの内容を表す説明図である。
FIG. 8 is an explanatory diagram showing the contents of a memory while the central processing unit 1 is processing a program.

【図9】 中央処理部1がプログラムを処理している間
のメモリの内容を表す説明図である。
FIG. 9 is an explanatory diagram showing the contents of a memory while the central processing unit 1 is processing a program.

【図10】 中央処理部1の処理を表すフローチャート
図である。
FIG. 10 is a flowchart illustrating the processing of the central processing unit 1;

【図11】 中央処理部1の処理を表すフローチャート
図である。
FIG. 11 is a flowchart illustrating a process of the central processing unit 1;

【図12】 中央処理部1の処理を表すフローチャート
図である。
FIG. 12 is a flowchart illustrating a process of the central processing unit 1;

【図13】 中央処理部1の処理を表すフローチャート
図である。
FIG. 13 is a flowchart illustrating the processing of the central processing unit 1.

【図14】 本発明の実施の形態に係るメモリ管理装置
のもう一つの構成ブロック図である。
FIG. 14 is another configuration block diagram of the memory management device according to the embodiment of the present invention.

【図15】 中央処理部1の処理を表すフローチャート
図である。
FIG. 15 is a flowchart illustrating the processing of the central processing unit 1.

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

1 中央処理部、2 プログラムメモリ、3 タイマ
部、4 ヒープメモリ、5 テーブル記憶部、6 スタ
ックメモリ、7 静的変数記憶部、8 ビデオインタフ
ェース、11 ビデオメモリ。
1 Central processing unit, 2 program memory, 3 timer unit, 4 heap memory, 5 table storage unit, 6 stack memory, 7 static variable storage unit, 8 video interface, 11 video memory.

フロントページの続き (72)発明者 領木 正人 愛知県丹羽郡大口町下小口5丁目25番地の 1 オークマ株式会社大口工場内 (72)発明者 直井 徹 岐阜県岐阜市福光南町1番地12−301号 Fターム(参考) 5B060 AA10 AA14 AC11 5B098 GD00 GD03 GD22 Continued on the front page (72) Inventor Masato Ryoki 5-25-25 Shimokoguchi, Oguchi-machi, Niwa-gun, Aichi Prefecture Inside the Oguchi Plant of Okuma Co., Ltd. F term (reference) 5B060 AA10 AA14 AC11 5B098 GD00 GD03 GD22

Claims (7)

【特許請求の範囲】[Claims] 【請求項1】 所定時間で処理終了するプログラムのた
めに、オブジェクトごとにメモリ領域を割り当てて、メ
モリを管理するメモリ管理方法であって、 新規のオブジェクトを生成する際には、前記メモリ領域
のうち未使用のものを選択し、当該選択した未使用のメ
モリ領域にオブジェクトを格納するステップと、 前記メモリ領域に格納されたオブジェクトを指し示すポ
インタ変数のうち、ヒープメモリまたは静的変数領域に
格納されているポインタ変数の数を参照カウントとし
て、当該メモリ領域に対応づけて管理するステップと、 前記プログラムが終了した際に各メモリ領域に対応づけ
られた参照カウントを調べ、参照カウントが0である
と、対応するメモリ領域を未使用として設定するステッ
プと、 を含むことを特徴とするメモリ管理方法。
1. A memory management method for managing a memory by allocating a memory area for each object for a program that terminates processing in a predetermined time, wherein a new object is generated when a new object is generated. Selecting an unused one of them, storing the object in the selected unused memory area, and storing, in a heap memory or a static variable area, a pointer variable pointing to the object stored in the memory area. Managing the number of pointer variables as a reference count in association with the memory area; and examining the reference counts associated with the respective memory areas when the program ends, and determining that the reference count is 0. Setting the corresponding memory area as unused. Method.
【請求項2】 請求項1に記載のメモリ管理方法におい
て、さらに、前記プログラムが終了する際に、0になっ
ている参照カウントに対応するメモリ領域に格納された
オブジェクト内部を検索し、当該オブジェクトから参照
されているメモリ領域に対応づけられた参照カウントを
デクリメントするステップを含むことを特徴とするメモ
リ管理方法。
2. The memory management method according to claim 1, further comprising: when the program ends, searching inside an object stored in a memory area corresponding to a reference count that is zero. Decrementing a reference count associated with a memory area referred to from the memory management method.
【請求項3】 請求項1に記載のメモリ管理方法におい
て、前記プログラムは、割り込み処理プログラムである
ことを特徴とするメモリ管理方法。
3. The memory management method according to claim 1, wherein the program is an interrupt processing program.
【請求項4】 請求項1に記載のメモリ管理方法におい
て、前記プログラムは、定期的に実行されることを特徴
とするメモリ管理方法。
4. The memory management method according to claim 1, wherein said program is executed periodically.
【請求項5】 所定時間で処理終了するプログラムのた
めに、オブジェクトごとにメモリ領域を割り当てて、メ
モリを管理するメモリ管理装置であって、 新規のオブジェクトを生成する際には、前記メモリ領域
のうち未使用のものを選択し、当該選択した未使用のメ
モリ領域にオブジェクトを格納する手段と、 前記メモリ領域に格納されたオブジェクトを指し示すポ
インタ変数のうち、ヒープメモリまたは静的変数領域に
格納されているポインタ変数の数を参照カウントとし
て、当該メモリ領域に対応づけて管理する手段と、 前記プログラムが終了した際に各メモリ領域に対応づけ
られた参照カウントを調べ、参照カウントが0である
と、対応するメモリ領域を未使用として設定する手段
と、 を含むことを特徴とするメモリ管理装置。
5. A memory management device which manages a memory by allocating a memory area for each object for a program which terminates processing in a predetermined time, wherein a new object is generated when a new object is generated. Means for selecting an unused one and storing the object in the selected unused memory area; and a pointer variable pointing to the object stored in the memory area, which is stored in the heap memory or the static variable area. Means for managing the number of pointer variables as reference counts in association with the corresponding memory area, and examining the reference counts associated with the respective memory areas when the program ends, and if the reference count is 0 And a means for setting a corresponding memory area as unused.
【請求項6】 請求項5に記載のメモリ管理装置におい
て、前記プログラムは、割り込み処理プログラムである
ことを特徴とするメモリ管理装置。
6. The memory management device according to claim 5, wherein the program is an interrupt processing program.
【請求項7】 請求項5に記載のメモリ管理装置におい
て、前記プログラムは、定期的に実行されることを特徴
とするメモリ管理装置。
7. The memory management device according to claim 5, wherein the program is executed periodically.
JP28253699A 1999-10-04 1999-10-04 Memory management method and memory management device Pending JP2001101070A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP28253699A JP2001101070A (en) 1999-10-04 1999-10-04 Memory management method and memory management device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP28253699A JP2001101070A (en) 1999-10-04 1999-10-04 Memory management method and memory management device

Publications (1)

Publication Number Publication Date
JP2001101070A true JP2001101070A (en) 2001-04-13

Family

ID=17653750

Family Applications (1)

Application Number Title Priority Date Filing Date
JP28253699A Pending JP2001101070A (en) 1999-10-04 1999-10-04 Memory management method and memory management device

Country Status (1)

Country Link
JP (1) JP2001101070A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20030094658A (en) * 2002-06-07 2003-12-18 이승룡 Method for explicit dynamic memory management in a system based on automatic dynamic memory management by an application program
KR100497722B1 (en) * 2002-07-02 2005-06-23 주식회사 인터와이즈 Method for controlling memory data storage area, computer readable medium storing the method thereon, and application program executing device
US20180314236A1 (en) 2017-04-27 2018-11-01 Fanuc Corporation Numerical controller

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20030094658A (en) * 2002-06-07 2003-12-18 이승룡 Method for explicit dynamic memory management in a system based on automatic dynamic memory management by an application program
KR100497722B1 (en) * 2002-07-02 2005-06-23 주식회사 인터와이즈 Method for controlling memory data storage area, computer readable medium storing the method thereon, and application program executing device
US20180314236A1 (en) 2017-04-27 2018-11-01 Fanuc Corporation Numerical controller
CN108803498A (en) * 2017-04-27 2018-11-13 发那科株式会社 Numerical control device
JP2018185734A (en) * 2017-04-27 2018-11-22 ファナック株式会社 Numerical control device
CN108803498B (en) * 2017-04-27 2019-06-14 发那科株式会社 Numerical control device
US10551823B2 (en) 2017-04-27 2020-02-04 Fanuc Corporation Numerical controller

Similar Documents

Publication Publication Date Title
US7069279B1 (en) Timely finalization of system resources
US5960206A (en) Method and apparatus for estimating installation time in a data processing system
US6393439B1 (en) Stored data object marking for garbage collectors
US20050021547A1 (en) Performance monitoring method in a distributed processing system
US6339779B1 (en) Reference counting mechanism for garbage collectors
JP2004005486A (en) Method for optimizing memory use state of computer application
US6941522B2 (en) Methods and apparatus for implementing a progress reporting interface
US6360233B1 (en) Dynamic memory space allocation
EP1311954A2 (en) Memory garbage collection method and apparatus
US7047389B2 (en) Memory allocation method and computer readable medium
CN111445292A (en) Method for automatically matching coupon to reach user
JP2001101070A (en) Memory management method and memory management device
JP2000155719A (en) Backup and restoration system for data and asynchronous data managing method
KR100857036B1 (en) Failure recovery method and device using transaction log file in billing system
US20050021576A1 (en) Mostly concurrent garbage collection
JPH0465711A (en) Display control system for display device
CN206480045U (en) A kind of customer care server and customer service system
JP2000020619A (en) Transaction compensation system
JP2004234546A (en) Program running method and device
CN117648381B (en) Data synchronization method and device based on real-time transaction
JP4431126B2 (en) Timing chart creation support system, timing chart creation support method, and timing chart creation support program
CN109726243A (en) A kind of purpose data classifying method, apparatus and system
US8473529B2 (en) Single pass marking of finalizable objects
JP3365133B2 (en) Telelighting device
JP2518390B2 (en) System performance monitoring method