JP2005157714A - Memory management system - Google Patents

Memory management system Download PDF

Info

Publication number
JP2005157714A
JP2005157714A JP2003394923A JP2003394923A JP2005157714A JP 2005157714 A JP2005157714 A JP 2005157714A JP 2003394923 A JP2003394923 A JP 2003394923A JP 2003394923 A JP2003394923 A JP 2003394923A JP 2005157714 A JP2005157714 A JP 2005157714A
Authority
JP
Japan
Prior art keywords
memory
size
data
area
kilobytes
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
JP2003394923A
Other languages
Japanese (ja)
Other versions
JP4033829B2 (en
Inventor
Tadashi Ito
忠 伊藤
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.)
Kyocera Document Solutions Inc
Original Assignee
Kyocera Mita Corp
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 Kyocera Mita Corp filed Critical Kyocera Mita Corp
Priority to JP2003394923A priority Critical patent/JP4033829B2/en
Publication of JP2005157714A publication Critical patent/JP2005157714A/en
Application granted granted Critical
Publication of JP4033829B2 publication Critical patent/JP4033829B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Abstract

<P>PROBLEM TO BE SOLVED: To provide a memory management system which can suppress occurrence of fragmentation of a memory area and can perform rapid allocation processing. <P>SOLUTION: The memory management system, which selects free space of the memory area for data to which allocation has been requested, and allocates the memory in an area of variable length, is provided with a reference size storage means which stores a reference size used for deciding whether the search direction in the space area is to be in an ascending order or a descending order of the memory addresses. The search direction is set in the descending order (S3) if the size of the data is equal to or more than the reference size, the search direction is set in the ascending order (S4) if the size is smaller than the reference size, and free space searched out at first as space with a size not smaller than the size of the data is selected to allocate (S5, S6) the memory for the data. <P>COPYRIGHT: (C)2005,JPO&NCIPI

Description

本発明は、情報処理装置や画像処理装置などのメモリを使用する装置に適用可能なメモリ管理システムに関する。   The present invention relates to a memory management system applicable to an apparatus using a memory such as an information processing apparatus or an image processing apparatus.

従来より、メモリ領域に対して割り付け要求がなされた際に、散在する空き領域中のいずれかを選択し、可変長の領域のメモリを割り付ける(動的にメモリを割り付ける)場合の代表的なアルゴリズムとして、最初適合(first−fit)法と最良適合(best−fit)法の2種類が一般的に知られている。   Conventionally, when an allocation request is made for a memory area, a representative algorithm for selecting one of the scattered free areas and allocating a variable-length area memory (dynamically allocating memory) In general, two types of methods are generally known: a first-fit method and a best-fit method.

最初適合法とは、割り付けを要求されたデータが格納され得る空き領域を、空き領域のサイズの大きさに関係なくメモリアドレスの昇順に探査し、最初に探査された空き領域を選択して割り付けを行う方法である。   The first adaptation method searches for free areas where data requested to be allocated can be stored, in ascending order of memory addresses regardless of the size of the free area, and selects and allocates the first searched free area. It is a method to do.

また、最良適合法とは、メモリ中に散在している全ての空き領域を探査し、割り付け要求のあったデータのサイズとの差が最小となるようなサイズの空き領域を選択して割り付けを行う方法である。   In addition, the best adaptation method searches all free areas scattered in the memory, selects free areas with a size that minimizes the difference from the size of the data requested for allocation, and allocates them. How to do it.

また、他の従来技術として、過去の割り付け要求がされたデータのサイズの統計をとって、その大きさに準じてクラス分けをし、割り付け要求の回数が多いクラス順に、割り付け要求サイズに適合する空き領域を選択するものがある(例えば、特許文献1参照)。
特開平09−016463号公報
As another conventional technique, statistics on the size of data requested for past allocation are taken and classified according to the size, so that the allocation request size is adapted in the order of classes with the highest number of allocation requests. Some select an empty area (see, for example, Patent Document 1).
Japanese Patent Laid-Open No. 09-016463

<<背景技術の動作の説明:具体例1>>
最初適合法のアルゴリズムを適用した従来のメモリ管理システムの動作を、図7に示される具体例を用いて説明する。図7は、最初適合法のアルゴリズムを適用した従来のメモリ管理システムにおけるメモリ105の使用状況の第1例を示す図である。
<< Description of Background Art Operation: Specific Example 1 >>
The operation of the conventional memory management system to which the algorithm of the first adaptation method is applied will be described using a specific example shown in FIG. FIG. 7 is a diagram showing a first example of the usage state of the memory 105 in the conventional memory management system to which the algorithm of the first adaptation method is applied.

図7(a)は、メモリ105に対して、全領域が未使用(空き)の状態から、サイズが1キロバイトと32キロバイトのデータの割り付けを、交互にそれぞれ4回づつ行った後のメモリ105の使用状況を表している。図7(b)は、図7(a)の状態から、サイズが1キロバイトのデータを割り付けられた4つの領域を削除(開放)した後のメモリ105の使用状況を表している。   FIG. 7A shows the memory 105 after the allocation of the data of 1 kilobyte and 32 kilobytes is alternately performed four times for each of the memory 105 from a state in which the entire area is unused (free). It shows the usage status. FIG. 7B shows the usage state of the memory 105 after deleting (releasing) the four areas to which data having a size of 1 kilobyte is allocated from the state of FIG. 7A.

メモリ105は複数の情報(データ)を記憶することができ、また、各情報を記憶する場所を特定するための番号がメモリ105には付されている。この番号をアドレス(番地)、またはメモリアドレスといい、例えば16進数表示で0x0000〜0x8000までの連番がアドレスとして付される。この場合の「0x0000」、「0x8000」のアドレスをそれぞれ最上位アドレス、最下位アドレスという。また、2つのアドレスを比較した際、番号(数字)が小さい方を上位アドレス、番号が大きい方を下位アドレスという。   A plurality of pieces of information (data) can be stored in the memory 105, and a number for identifying a place where each piece of information is stored is given to the memory 105. This number is referred to as an address (address) or a memory address. For example, serial numbers from 0x0000 to 0x8000 in hexadecimal notation are assigned as addresses. In this case, the addresses “0x0000” and “0x8000” are referred to as the highest address and the lowest address, respectively. When two addresses are compared, the smaller number (number) is called the upper address, and the larger number is called the lower address.

図7(a)及び図7(b)の図中において、上方側がメモリ105の上位アドレス側、下方側が下位アドレス側を表しており、メモリ105の上端はそれぞれの最上位アドレス、下端はそれぞれの最下位アドレスに対応している。   In FIG. 7A and FIG. 7B, the upper side represents the upper address side of the memory 105 and the lower side represents the lower address side. The upper end of the memory 105 is the most significant address, and the lower end is the respective upper address. Corresponds to the lowest address.

図7(a)に示されるように、最初適合法においては、割り付けを要求されたデータが格納され得る空き領域を、空き領域のサイズの大きさに関係なくメモリアドレスの昇順に探査し、最初に探査された空き領域を選択して割り付けを行うため、サイズが1キロバイトと32キロバイトのデータの割り付けが、メモリ105の最上位アドレスより交互に、且つ連続してなされている。尚、データの割り付けがなされた領域は、図中「使用中」と表されており、サイズが1キロバイトと32キロバイトのデータの割り付けがなされていない領域は、空き領域(図中「空き」と表示)となっている。   As shown in FIG. 7A, in the first adaptation method, a free area in which data requested to be allocated can be stored is searched in ascending order of memory addresses regardless of the size of the free area. Therefore, the allocation of data having a size of 1 kilobyte and 32 kilobytes is performed alternately and continuously from the highest address of the memory 105. The area to which data is allocated is indicated as “in use” in the figure, and the area to which data of 1 kilobyte and 32 kilobytes is not allocated is an empty area (“free” in the figure). Display).

そして、サイズが1キロバイトのデータを割り付けられた使用中の領域(計4つ)が削除されると、図7(b)に示されるように、サイズが32キロバイトのデータを割り付けられた使用中の領域と隣接して、サイズが1キロバイトの空き領域が4つ生成され、メモリ領域の断片化が生じることとなる。   When the in-use areas (total of 4) to which the data of 1 kilobyte is allocated are deleted, as shown in FIG. 7B, the in-use area to which the data of 32 kilobytes is allocated Four free areas having a size of 1 kilobyte are generated adjacent to the above area, resulting in fragmentation of the memory area.

尚、最初適合法のアルゴリズムを適用した従来のメモリ管理システムに関し、図7(a)、図7(b)を用いて上述の説明をしたが、最初適合法のアルゴリズムに代えて最良適合法のアルゴリズムを適用した場合であっても、最初適合法のアルゴリズムを適用した従来のメモリ管理システムと同様に、メモリ領域の断片化は生じることとなる。   The conventional memory management system to which the algorithm of the first adaptation method is applied has been described above with reference to FIGS. 7A and 7B. However, instead of the algorithm of the first adaptation method, Even when the algorithm is applied, the memory area is fragmented as in the conventional memory management system to which the algorithm of the first adaptation method is applied.

<<背景技術の動作の説明:具体例2>>
更に、図8に示される別の具体例を用いて、最初適合法のアルゴリズムを適用した従来のメモリ管理システムの動作を説明する。図8は、最初適合法のアルゴリズムを適用した従来のメモリ管理システムにおけるメモリ105の使用状況の第2例を示す図である。
<< Description of Background Art Operation: Specific Example 2 >>
Furthermore, the operation of the conventional memory management system to which the algorithm of the first adaptation method is applied will be described using another specific example shown in FIG. FIG. 8 is a diagram illustrating a second example of the usage state of the memory 105 in the conventional memory management system to which the algorithm of the first adaptation method is applied.

図8(a)は、当初、サイズが4キロバイト、20キロバイト、8キロバイト、32キロバイトの4つのデータ、及びその他のデータをメモリ105に割り付け、その後それら4つのデータ、即ちサイズが4キロバイト、20キロバイト、8キロバイト、32キロバイトのデータの割り付けを削除(開放)した場合のメモリ105の使用状況を表している。メモリ105に対する前記「4つのデータ」それぞれの割り付け前後にも、「他のデータ」の割り付けがなされており、それら「他のデータ」の割り付けは削除されていないものとする。それら「他のデータ」が割り付けられた領域は、図8(a)中、「使用中」と記載された部分に相当している。   FIG. 8 (a) initially allocates four data of size 4 kilobytes, 20 kilobytes, 8 kilobytes, 32 kilobytes, and other data to the memory 105, and then those four data, ie, the size of 4 kilobytes, 20 This shows the usage status of the memory 105 when the allocation of data of kilobytes, 8 kilobytes, and 32 kilobytes is deleted (released). It is assumed that “other data” is allocated before and after the allocation of the “four data” to the memory 105, and the allocation of these “other data” is not deleted. The areas to which these “other data” are assigned correspond to the portions described as “in use” in FIG.

図8(b)は、図8(a)の状態から、サイズが6キロバイトと32キロバイトのデータの割り付けを更に行った後のメモリ105の使用状況を表している。尚、図8(a)中、実線の矢印及び破線の矢印は、それぞれ更に割り付けを要求されたサイズが6キロバイト、32キロバイトのデータが格納されるべき空き領域を探査する順序を示している。   FIG. 8B shows the usage state of the memory 105 after further allocation of data of 6 kilobytes and 32 kilobytes in size from the state of FIG. In FIG. 8A, the solid line arrows and the broken line arrows indicate the order of searching for a free area in which data of 6 kilobytes and 32 kilobytes, which are requested to be allocated, are stored.

図8(a)及び図8(b)の図中において、上方側がメモリ105の上位アドレス側、下方側が下位アドレス側を表しており、メモリ105の上端はそれぞれの最上位アドレス、下端はそれぞれの最下位アドレスに対応している。また、メモリ105において、当初割り付けられた「サイズが4キロバイト、20キロバイト、8キロバイト、32キロバイトの4つのデータ」は、サイズが4キロバイト、20キロバイト、8キロバイト、32キロバイトのデータの順に割り付けられたものとし、それぞれの割り付けが開放された後の空き領域を、以下、それぞれ空きA、空きB,空きC,空きDと言う。   8A and 8B, the upper side represents the upper address side of the memory 105 and the lower side represents the lower address side. The upper end of the memory 105 is the uppermost address and the lower end is the respective upper address. Corresponds to the lowest address. In addition, in the memory 105, the “4 data having a size of 4 kilobytes, 20 kilobytes, 8 kilobytes, and 32 kilobytes” that are initially allocated are allocated in the order of data having a size of 4 kilobytes, 20 kilobytes, 8 kilobytes, and 32 kilobytes. The empty areas after the respective allocations are released are hereinafter referred to as empty A, empty B, empty C, and empty D, respectively.

最初適合法においては、割り付けを要求されたデータが格納され得る空き領域を、空き領域のサイズの大きさに関係なくメモリアドレスの昇順に探査し、最初に探査された空き領域を選択して割り付けを行うため、当初割り付けられた「サイズが4キロバイト、20キロバイト、8キロバイト、32キロバイトの4つのデータ」は、メモリ105の上位アドレス側からこの順番で割り付けられ、それら4つのデータに係る割り付けが開放された後は、図8(a)に示されるようなメモリの使用状況となる。即ち、メモリ105の上位アドレス側から、空きA、空きB、空きC、空きDの順番に空き領域が発生する。   In the first adaptation method, the free space where the data requested to be allocated can be stored is searched in ascending order of memory address regardless of the size of the free space, and the first free space searched is selected and allocated. Therefore, the “4 data of size 4 KB, 20 KB, 8 KB, 32 KB” that were initially allocated are allocated in this order from the upper address side of the memory 105, and the allocation related to these 4 data is After being released, the memory is used as shown in FIG. That is, empty areas are generated in the order of empty A, empty B, empty C, and empty D from the upper address side of the memory 105.

そして、図8(a)の状態から更にサイズが6キロバイトのデータの割り付けを行う際、以下のように、上位アドレス側から空き領域が探査される(図8(a)中の実線の矢印を参照)。
(ステップ1):空きAのサイズ(4キロバイト)と、6キロバイトが比較されるが、割り付けできないので、次の空き領域を検索する。
(ステップ2):空きBのサイズ(20キロバイト)に、6キロバイトのサイズのメモリ領域を確保することができるため、空きBを選択して割り付ける。
When data having a size of 6 kilobytes is further allocated from the state of FIG. 8A, a free area is searched from the higher address side as follows (the solid line arrow in FIG. 8A is indicated). reference).
(Step 1): The size of free space A (4 kilobytes) is compared with 6 kilobytes, but cannot be allocated, so the next free space is searched.
(Step 2): Since a memory area having a size of 6 kilobytes can be secured to the size of the free space B (20 kilobytes), the free space B is selected and allocated.

このように、サイズが6キロバイトのデータの割り付けにとっては、より空き領域のサイズとの差が小さい空きC(サイズが8キロバイト)を選択するのが最適であるのに関わらず、最初適合法のアルゴリズムを適用した場合は、空きBを選択してしまう。従って、図8(b)に示すように、空きBにサイズが6キロバイトのデータを割り付けることで残存した新たな空き領域(空きB’)のサイズは、20キロバイトから6キロバイトを差し引いた14キロバイトになり、次回、サイズが20キロバイトのデータについて割り付け要求が発生した時、そのデータを空きB’に格納できなくなる(つまり、メモリ不足となる)。   Thus, for the allocation of data with a size of 6 kilobytes, regardless of whether it is optimal to select free space C (size is 8 kilobytes) with a smaller difference from the free space size, When the algorithm is applied, the vacant B is selected. Therefore, as shown in FIG. 8B, the size of the new free area (free B ′) remaining by allocating the data of 6 kilobytes to the free space B is 14 kilobytes obtained by subtracting 6 kilobytes from 20 kilobytes. Next time, when an allocation request is generated for data having a size of 20 kilobytes, the data cannot be stored in the free space B ′ (that is, the memory becomes insufficient).

また、図8(a)の状態から更にサイズが32キロバイトのデータの割り付けを行う際、以下のように、上位アドレス側から空き領域が探査される(図8(a)中の破線の矢印を参照)。
(ステップ1):空きAのサイズ(4キロバイト)と、32キロバイトが比較されるが、割り付けできないので、次の空き領域を検索する。
(ステップ2):空きBのサイズ(20キロバイト)と、32キロバイトが比較されるが、割り付けできないので、次の空き領域を検索する。
(ステップ3):空きCのサイズ(8キロバイト)と、32キロバイトが比較されるが、割り付けできないので、次の空き領域を検索する。
(ステップ4):空きDのサイズ(32キロバイト)に、32キロバイトのサイズのメモリ領域を確保することができるため、空きDを選択して割り付ける。
Further, when allocating data having a size of 32 kilobytes further from the state of FIG. 8A, an empty area is searched from the upper address side as follows (the broken line arrow in FIG. 8A). reference).
(Step 1): The size of free space A (4 kilobytes) is compared with 32 kilobytes, but cannot be allocated, so the next free space is searched.
(Step 2): The size of free B (20 kilobytes) is compared with 32 kilobytes, but cannot be allocated, so the next free area is searched.
(Step 3): The size of free C (8 kilobytes) is compared with 32 kilobytes, but cannot be allocated, so the next free area is searched.
(Step 4): Since a memory area having a size of 32 kilobytes can be secured to the size of the free space D (32 kilobytes), the free space D is selected and allocated.

このように、最初適合法のアルゴリズムを適用した場合は、サイズが32キロバイトのデータが格納され得る空きDを選択するまでに、空きDの位置するアドレスより上位にある全ての空き領域(空きA、空きB、空きC)についても選択できるか否かの判断を行うことになり、無駄が生じ、割り付け処理に多大な時間を費やしてしまう。   As described above, when the algorithm of the first adaptation method is applied, all the empty areas (empty A) higher than the address where the empty D is located before the empty D in which the data of 32 kilobytes can be stored are selected. , Empty B, empty C) is determined whether or not it can be selected, resulting in waste and a great deal of time for the allocation process.

<<背景技術の動作の説明:具体例3>>
更に、図9に示される別の具体例を用いて、最初適合法のアルゴリズムを適用した従来のメモリ管理システムの動作を説明する。図9は、最初適合法のアルゴリズムを適用した従来のメモリ管理システムにおけるメモリ105の使用状況の第3例を示す図である。
<< Description of Background Art Operation: Specific Example 3 >>
Furthermore, the operation of the conventional memory management system to which the algorithm of the first adaptation method is applied will be described using another specific example shown in FIG. FIG. 9 is a diagram showing a third example of the usage state of the memory 105 in the conventional memory management system to which the algorithm of the first adaptation method is applied.

図9(a)はメモリ105に対して、全領域が未使用(空き)の状態から複数のデータの割り付けを行った後のメモリ105の使用状況を表したものである。但し、その割り付け後も、メモリ105には空き領域が残存しているものとする。   FIG. 9A shows the usage state of the memory 105 after a plurality of data are allocated to the memory 105 from a state where all areas are unused (empty). However, it is assumed that an empty area remains in the memory 105 even after the allocation.

図9(a)及び図9(b)の図中において、上方側がメモリ105の上位アドレス側、下方側が下位アドレス側を表しており、メモリ105の上端はそれぞれの最上位アドレス、下端はそれぞれの最下位アドレスに対応している。   9A and 9B, the upper side represents the upper address side of the memory 105, and the lower side represents the lower address side. The upper end of the memory 105 is the uppermost address, and the lower end is the respective upper address. Corresponds to the lowest address.

最初適合法においては、割り付けを要求されたデータが格納され得る空き領域を、空き領域のサイズの大きさに関係なくメモリアドレスの昇順に探査し、最初に探査された空き領域を選択して割り付けを行うため、図9(a)に示すように、メモリ105の上位アドレス側にまとまってデータが割り付けられて「使用中」となっており、下位アドレス側は空き領域(図中、「空き」と表示)となっている。   In the first adaptation method, the free space where the data requested to be allocated can be stored is searched in ascending order of memory address regardless of the size of the free space, and the first free space searched is selected and allocated. Therefore, as shown in FIG. 9A, the data is collectively allocated to the upper address side of the memory 105 and becomes “in use”, and the lower address side has an empty area (in the figure, “empty”). Is displayed).

図9(b)は、図9(a)の状態から、新たにサイズがそれぞれ8キロバイト、20キロバイト、32キロバイトのデータS、データT、データUに対する割り付けを、この順番で行った場合のメモリ105の使用状況を表したものである。最初適合法においては、割り付けを要求されたデータが格納され得る空き領域を、空き領域のサイズの大きさに関係なくメモリアドレスの昇順に探査し、最初に探査された空き領域を選択して割り付けを行うため、図9(b)に示すように、図9(a)で「使用中」であった領域に連続した下位アドレス側の領域に、データS、データT、データUに対する割り付けがこの順番で行われる。   FIG. 9B shows the memory in the case where the allocation to the data S, data T, and data U having a size of 8 kilobytes, 20 kilobytes, and 32 kilobytes is newly performed in this order from the state of FIG. 9A. 105 shows the usage status. In the first adaptation method, the free space where the data requested to be allocated can be stored is searched in ascending order of memory address regardless of the size of the free space, and the first free space searched is selected and allocated. Therefore, as shown in FIG. 9B, the allocation to the data S, data T, and data U is performed in the area on the lower address side continuous to the area “in use” in FIG. Done in order.

次に、図9(b)の状態から、データS、データT、データUのいずれか1つを削除(開放)した場合のメモリ領域の断片化の発生の有無について検討する。   Next, whether or not fragmentation of the memory area occurs when any one of the data S, data T, and data U is deleted (released) from the state of FIG.

まず、図9(b)に示す状態にあるメモリ105からデータUの割り付けのみを削除(開放)しても、データUの割り付けられた領域は既に存在している空き領域と隣接しているため、メモリ領域の断片化は生じない。   First, even if only the allocation of the data U is deleted (released) from the memory 105 in the state shown in FIG. 9B, the allocated area of the data U is adjacent to the already existing empty area. The memory area is not fragmented.

しかし、図9(b)に示す状態にあるメモリ105からデータTの割り付けのみを削除(開放)すると、データTの割り付けられた領域は、データSとデータUの割り付けられた領域の間にあるため、メモリ領域の断片化が生じる。   However, if only the allocation of the data T is deleted (released) from the memory 105 in the state shown in FIG. 9B, the area to which the data T is allocated is between the areas to which the data S and the data U are allocated. Therefore, fragmentation of the memory area occurs.

更に、図9(b)に示す状態にあるメモリ105からデータSの割り付けのみを削除(開放)した場合でも、データSの割り付けられた領域は既に存在している空き領域に隣接していないため、メモリ領域の断片化が生じてしまう。従って、(後述するように本発明と比較にした場合に明らかとなるが)最初適合法のアルゴリズムを採用した場合はメモリ領域の断片化が生じやすいと言える。   Further, even when only the allocation of the data S is deleted (released) from the memory 105 in the state shown in FIG. 9B, the area to which the data S is allocated is not adjacent to the existing empty area. This will cause fragmentation of the memory area. Therefore, it can be said that fragmentation of the memory area is likely to occur when the first adaptation algorithm is adopted (as will be apparent when compared with the present invention as will be described later).

上述のとおり、最初適合法を採用した場合、常にメモリ領域の先頭から空き領域が探査され、割り付けを要求されたデータを格納し得る空き領域が見つかり次第割り付けがなされるため、必然的にメモリ領域の先頭付近の利用頻度が他の部分に比べて高くなる。従って、メモリ領域の先頭付近にメモリ領域の断片化(フラグメンテーション)が頻繁に発生し、メモリ不足が発生しやすくなるという問題があった。また、割り付けを要求されたデータを格納し得る空き領域がメモリアドレスの下位アドレス側にしかない場合であっても、その空き領域より上位アドレス側にある全ての空き領域に対し選択できるか否かの判断を行うため、無駄が生じ、割り付け処理に多大な時間を費やしてしまうという問題があった。   As described above, when the first adaptation method is adopted, a free area is always searched from the beginning of the memory area, and allocation is performed as soon as a free area that can store the requested data is found. The usage frequency near the top of is higher than other parts. Accordingly, there is a problem in that fragmentation (fragmentation) of the memory area frequently occurs near the top of the memory area, and memory shortage tends to occur. Whether or not all the free areas on the higher address side than the free area can be selected even when the free area that can store the data requested to be allocated is only on the lower address side of the memory address. Since the determination is made, there is a problem that waste occurs and a lot of time is spent in the allocation process.

また、最良適合法を採用した場合、メモリ領域中に散在している空き領域の全てを探査する必要があるため、割り付け処理に費やす時間が大きくなるという問題があった。   In addition, when the best adaptation method is adopted, it is necessary to search all the empty areas scattered in the memory area, and there is a problem that the time spent for the allocation process increases.

また、特許文献1に記載の従来構成例は、空き領域の無駄な検索処理を軽減することを目的としているが、割り付け要求がされた回数が少ないクラスに属するサイズの割り付け要求がされた場合は、結局最後に探査されるため、かえって割り付け処理に多大な時間を費やしてしまう。従って、選択される全てのサイズについて統計的に見ると、割り付け処理の迅速性に問題があった。   In addition, the conventional configuration example described in Patent Document 1 aims to reduce useless search processing of a free area, but when an allocation request for a size belonging to a class with a small number of allocation requests is made. After all, since it is finally explored, it takes a lot of time for the allocation process. Accordingly, when all the sizes to be selected are statistically viewed, there is a problem in the speed of the allocation process.

本発明は、上記の点に鑑み、メモリ領域の断片化の発生を抑制すると共に、高速な割り付け処理を行うことができるメモリ管理システムを提供することを目的とする。   In view of the above-described points, an object of the present invention is to provide a memory management system capable of suppressing the occurrence of fragmentation of a memory area and performing high-speed allocation processing.

上記目的を達成するために本発明は、割り付けを要求されたデータに対して、当該メモリ領域の空き領域を選択して可変長の領域のメモリの割り付けを行うメモリ管理システムにおいて、前記空き領域の探査方向を決するために用いる基準サイズを記憶する基準サイズ記憶手段を備え、前記データのサイズが前記基準サイズより大きい場合と小さい場合とで、前記探査方向をメモリアドレスの昇順とするかと降順とするかとを互いに逆にしつつ、前記データのサイズ以上のサイズを有するものとして最初に探査された空き領域を選択して前記データに対するメモリの割り付けを行うようにしている。   In order to achieve the above object, the present invention provides a memory management system for selecting a free area of a memory area and allocating a memory of a variable-length area for data requested to be allocated. Reference size storage means for storing a reference size used for determining the search direction is provided, and the search direction is set to ascending order or descending order of the memory address depending on whether the data size is larger or smaller than the reference size. While the heels are reversed, the free space first searched for as having a size equal to or larger than the size of the data is selected and the memory is allocated to the data.

これにより、メモリ領域の断片化の発生を抑制すると共に、高速な割り付け処理を行うことができる。   As a result, the occurrence of fragmentation of the memory area can be suppressed and high-speed allocation processing can be performed.

また、前記データのサイズ以上のサイズを有する空き領域がない場合に、前記基準サイズを前記データのサイズで書き換えて記憶するようにしても良い。   Further, when there is no empty area having a size larger than the size of the data, the reference size may be rewritten and stored with the size of the data.

これにより、前記基準サイズは、割り付け要求元であるプログラム等にとって適切な(統計的に最適な)値に自動的に更新される。   Thereby, the reference size is automatically updated to a value (statistically optimal) appropriate for the program or the like that is the allocation request source.

上述した通り、本発明に係るメモリ管理システムによれば、メモリ領域の断片化の発生を抑制すると共に、高速な割り付け処理を行うことができる。   As described above, according to the memory management system of the present invention, it is possible to suppress the occurrence of fragmentation of the memory area and perform high-speed allocation processing.

以下、本発明について図面を参照しながら詳細に説明する。図1は、本発明の実施の形態に係るメモリ管理システム10の構成図であり、中央演算処理装置(Central Processing Unit)1(以下「CPU1」という)によって制御が行われるオペレーティングシステム2(以下「OS2」という)上で、プログラム3が稼動している例である。   Hereinafter, the present invention will be described in detail with reference to the drawings. FIG. 1 is a configuration diagram of a memory management system 10 according to an embodiment of the present invention. An operating system 2 (hereinafter “CPU 1”) controlled by a central processing unit 1 (hereinafter “CPU 1”) is illustrated. This is an example in which the program 3 is running on OS2).

プログラム3やOS2がメモリを必要とする処理を行う際、そのメモリの要求はCPU1に送られて、CPU1からメモリ管理手段4にメモリ要求として送出される。メモリ管理手段4は、このメモリ要求を受けてメモリ5内に要求されたサイズのメモリ領域を割り付けて確保する。その場合、メモリ管理手段4は割り付けを行う前処理として、管理領域6で記憶されているメモリ5に関する管理情報を参照して、メモリ5内における空き領域を探査する。   When the program 3 or OS 2 performs a process that requires memory, the memory request is sent to the CPU 1 and sent from the CPU 1 to the memory management unit 4 as a memory request. In response to this memory request, the memory management means 4 allocates and secures a memory area of the requested size in the memory 5. In that case, the memory management means 4 searches for a free area in the memory 5 by referring to the management information related to the memory 5 stored in the management area 6 as a pre-process for performing allocation.

本実施形態に係るメモリ管理システム10は、メモリ5の管理を可変長メモリ管理方式、即ちメモリ5に対して割り付け要求がなされた際に、散在する空き領域中のいずれかを選択し、可変長の領域のメモリを割り付ける(動的にメモリを割り付ける)方式を採用している。   The memory management system 10 according to the present embodiment selects one of the scattered free areas when the allocation of the memory 5 is requested to the memory 5, ie, when the allocation request is made to the memory 5, and the variable length This method employs a method of allocating memory in the area (dynamically allocating memory).

メモリ5は複数の情報(データ)を記憶することができ、また、各情報を記憶する場所を特定するための番号がメモリ5には付されている。この番号をアドレス(番地)、またはメモリアドレスといい、例えば16進数表示で0x0000〜0x8000までの連番がアドレスとして付される。この場合の「0x0000」、「0x8000」のアドレスをそれぞれ最上位アドレス、最下位アドレスという。また、2つのアドレスを比較した際、番号(数字)が小さい方を上位アドレス、番号が大きい方を下位アドレスという。尚、説明の便宜上、図1においてメモリ5と管理領域6は分離して記載しているが、管理領域6は、メモリ5の内部に設けても構わない。   The memory 5 can store a plurality of pieces of information (data), and a number for identifying a place where each piece of information is stored is given to the memory 5. This number is referred to as an address (address) or a memory address. For example, serial numbers from 0x0000 to 0x8000 in hexadecimal notation are assigned as addresses. In this case, the addresses “0x0000” and “0x8000” are referred to as the highest address and the lowest address, respectively. When two addresses are compared, the smaller number (number) is called the upper address, and the larger number is called the lower address. For convenience of explanation, the memory 5 and the management area 6 are illustrated separately in FIG. 1, but the management area 6 may be provided inside the memory 5.

以下、本実施形態に係るメモリ管理システム10のメモリ領域の割り付け動作について、図2を参照しながら説明する。図2は、図1におけるメモリ管理システム10の動作を説明するためのフローチャートである。   The memory area allocation operation of the memory management system 10 according to the present embodiment will be described below with reference to FIG. FIG. 2 is a flowchart for explaining the operation of the memory management system 10 in FIG.

まず、ステップS1において、データのサイズがαの割り付け要求が発生したとする。ステップS1を経て移行するステップS2では、サイズαが、管理領域6に記憶されている「基準サイズ」と比較される。ここで、この「基準サイズ」は、後述するように空き領域の探査方向をメモリアドレスの昇順とするか降順とするかを決定するために用いられるものであり、後述するように、初期値は駆動するプログラム3やOS2に応じて適宜決定される。   First, in step S1, it is assumed that an allocation request having a data size α is generated. In step S <b> 2 that moves through step S <b> 1, the size α is compared with the “reference size” stored in the management area 6. Here, the “reference size” is used to determine whether the exploration direction of the free area is ascending order or descending order of the memory address, as will be described later. It is determined appropriately according to the program 3 and OS 2 to be driven.

サイズαが「基準サイズ」以上である場合は(ステップS2のY)、空き領域の探査方向を降順と決定する(ステップS3)。即ち、メモリ5内の最下位アドレスより上位アドレス側に向かって空き領域を探査する(例えば、メモリアドレス0x8000より0x0000に向かって探査する)よう探査方向を決定する。一方、サイズαが「基準サイズ」より小さい場合は(ステップS2のN)、空き領域の探査方向を昇順と決定する(ステップS4)。即ち、メモリ5内の最上位アドレスより下位アドレス側に向かって空き領域を探査する(例えば、メモリアドレス0x0000より0x8000に向かって探査する)よう探査方向を決定する。   When the size α is equal to or larger than the “reference size” (Y in Step S2), the search direction of the free area is determined as descending order (Step S3). That is, the search direction is determined so as to search for an empty area from the lowest address in the memory 5 toward the higher address side (for example, search from the memory address 0x8000 toward 0x0000). On the other hand, when the size α is smaller than the “reference size” (N in Step S2), the search direction of the free area is determined as ascending order (Step S4). That is, the search direction is determined so as to search for an empty area from the highest address in the memory 5 toward the lower address side (for example, search from the memory address 0x0000 toward 0x8000).

尚、新たな割り付け要求が発生する度に(ステップS1が実行される度に)、ステップS2の判定はなされる為、その都度、空き領域の探査方向は変わりうる。   Since the determination in step S2 is made every time a new allocation request occurs (every time step S1 is executed), the exploration direction of the free area can change each time.

ステップS3又はステップS4で空き領域の探査方向が決定されると、その決定された探査方向で空き領域を探し、見つかった空き領域のサイズがサイズα以上であるか否かがチェックされる(ステップS5)。そして、その見つかった空き領域のサイズがサイズα以上である場合は(ステップS5のY)、その空き領域を選択して割り付けを要求されたデータの割り付けを行う(ステップS6)。   When the exploration direction of the free area is determined in step S3 or step S4, the free area is searched for in the determined exploration direction, and it is checked whether the size of the found free area is equal to or larger than the size α (step). S5). If the size of the found free area is equal to or larger than the size α (Y in step S5), the free area is selected and the data requested to be assigned is assigned (step S6).

一方、探査された空き領域のサイズがサイズαより小さい場合は、ステップS7に移行し、メモリ5の全領域にわたって空き領域の探査が行われたか否かを判定する。   On the other hand, if the size of the searched free area is smaller than the size α, the process proceeds to step S7, and it is determined whether or not the free area has been searched over the entire area of the memory 5.

未だ、メモリ5の全領域にわたって空き領域の探査が行われていない場合は(ステップS7のN)、上述のステップS5に戻り、引き続き空き領域の探査を行うが、既にメモリ5の全領域にわたって空き領域の探査を行っている場合は(ステップS7のY)、空き領域が不足しているため割り付けできないとして、ステップS8に移行する。   If the search for the empty area is not yet performed over the entire area of the memory 5 (N in step S7), the process returns to the above-described step S5 to continue the search for the empty area. If the area is being searched (Y in step S7), it is determined that allocation is not possible because there is not enough free area, and the process proceeds to step S8.

ステップS8では、メモリ管理手段4がCPU1に対して「割り付け不可能」の信号を伝達する等の割り付け不可能に係わるエラー処理を行うとともに、「基準サイズ」の値をサイズαの値で書き換える。この「基準サイズ」の値をサイズαの値で書き換えることの意義については後述する。   In step S8, the memory management means 4 performs error processing related to the inability to allocate, such as transmitting a signal “incapable of allocation” to the CPU 1, and rewrites the value of “reference size” with the value of size α. The significance of rewriting the value of “reference size” with the value of size α will be described later.

上述したように、メモリ管理システム10では、割り付けを要求されたデータのサイズαが「基準サイズ」以上の場合と「基準サイズ」未満の場合とで、空き領域の探査方向をメモリアドレスの昇順とするかと降順とするかとを互いに逆にしつつ(メモリアドレスの昇順とするかと降順とするかとを異にしつつ)、サイズα以上のサイズを有するものとして最初に探査された空き領域を選択して割り付けを要求されたデータの割り付けを行う。   As described above, in the memory management system 10, the exploration direction of the free area is set to the ascending order of the memory addresses in the case where the size α of the data requested to be allocated is greater than or equal to the “reference size” and less than the “reference size”. Selecting and allocating the first free space searched for having a size of size α or larger while reversing whether to do or descending (with different memory address ascending or descending order) Allocate the requested data.

<<動作の説明:具体例1>>
次に、背景技術の欄で説明した最初適合法のアルゴリズムを適用した従来のメモリ管理システムと比較しながら、本実施形態に係るメモリ管理システム10の動作を、図3に示される具体例を用いて説明する。図3は、図1における管理領域6に記憶される内容の一部及びメモリ5の使用状況の第1例を示す図であり、背景技術の欄で図7を用いて説明したメモリ領域の割り付け処理と同様の割り付け処理をメモリ管理システム10において実行させた場合のメモリの使用状況を示したものである。
<< Description of Operation: Specific Example 1 >>
Next, the operation of the memory management system 10 according to the present embodiment is compared with the conventional memory management system to which the algorithm of the first adaptation method described in the background art is applied, using the specific example shown in FIG. I will explain. FIG. 3 is a diagram showing a first example of a part of the contents stored in the management area 6 in FIG. 1 and the usage status of the memory 5, and the allocation of the memory area described with reference to FIG. 7 in the background art section The memory usage state when the allocation process similar to the process is executed in the memory management system 10 is shown.

図3(a)は、図7(a)と同様、メモリ5に対して全領域が未使用(空き)の状態から、サイズが1キロバイトと32キロバイトのデータの割り付けを交互にそれぞれ4回づつ行った後のメモリ5の使用状況を表している。図3(b)は、図7(b)と同様、図3(a)の状態から、サイズが1キロバイトのデータを割り付けられた4つの領域を開放した後のメモリ5の使用状況を表している。また、図3(a)及び図3(b)における管理領域6に記憶されている「基準サイズ」は、ともに16キロバイトとなっている。   In FIG. 3 (a), similarly to FIG. 7 (a), the allocation of data having a size of 1 kilobyte and 32 kilobytes is alternately performed four times from the state in which the entire area is unused (free) with respect to the memory 5. It shows the usage status of the memory 5 after being performed. FIG. 3B shows the usage status of the memory 5 after releasing the four areas allocated with data of 1 kilobyte in size from the state of FIG. 3A, as in FIG. 7B. Yes. Further, the “reference size” stored in the management area 6 in FIGS. 3A and 3B is both 16 kilobytes.

図3(a)及び図3(b)の図中において、上方側がメモリ5の上位アドレス側、下方側が下位アドレス側を表しており、メモリ5の上端はそれぞれの最上位アドレス、下端はそれぞれの最下位アドレスに対応している。   3A and 3B, the upper side represents the upper address side of the memory 5 and the lower side represents the lower address side. The upper end of the memory 5 is the most significant address and the lower end is the respective upper address. Corresponds to the lowest address.

割り付けを要求されたデータのサイズである1キロバイトは「基準サイズ」(16キロバイト未満)であるため、上述したように空き領域の探査方向は昇順となり(図2のステップS4参照)、32キロバイトは「基準サイズ」(16キロバイト)以上であるため、上述したように空き領域の探査方向は降順となる(図2のステップS3参照)。   Since 1 kilobyte, which is the size of the data requested to be allocated, is the “reference size” (less than 16 kilobytes), the search direction of the free area is ascending as described above (see step S4 in FIG. 2). Since it is equal to or larger than the “reference size” (16 kilobytes), the search direction of the empty area is in descending order as described above (see step S3 in FIG. 2).

従って、図3(a)に示されるように、メモリ5の最上位アドレスから下位アドレス側に向かってサイズが1キロバイトのデータが4つ連続して割り付けられ、最下位アドレスから上位アドレス側に向かってサイズが32キロバイトのデータが4つ連続して割り付けられる。また、データの割り付けのなされていないメモリ空間の中央付近には、1つの空き領域が残存する。   Accordingly, as shown in FIG. 3A, four pieces of data having a size of 1 kilobyte are continuously allocated from the highest address of the memory 5 to the lower address side, and from the lowest address to the higher address side. Thus, four pieces of data having a size of 32 kilobytes are continuously allocated. In addition, one free area remains in the vicinity of the center of the memory space to which no data is allocated.

そうすると、サイズが1キロバイトのデータを割り付けられた領域(計4つ)が削除されても、図3(b)に示されるように、サイズが1キロバイトの4つの空き領域は、サイズが32キロバイトのデータを割り付けられた領域と隣接していない上位アドレス側にまとまって発生するため、メモリ領域の断片化は生じず、図3(a)の状態から既に存在していた空き領域と削除された領域とを併合した1つの連続した空き領域が生成されることとなる。   Then, even if the area (total 4) to which the data with the size of 1 kilobyte is allocated is deleted, as shown in FIG. 3B, the four free areas with the size of 1 kilobyte have the size of 32 kilobytes. Since the data is collectively generated on the upper address side that is not adjacent to the allocated area, the memory area is not fragmented, and the existing free area is deleted from the state shown in FIG. One continuous free area that is merged with the area is generated.

背景技術の欄で図7を用いて説明した最初適合法のアルゴリズムを適用した従来のメモリ管理システムにおいて同様の処理を行うと、図7(b)に示されるようにメモリ105にはメモリ領域の断片化が生じてしまうが、上述したようにメモリ5にはメモリ領域の断片化が生じない。従って、本実施形態に係るメモリ管理システム10においては、メモリ領域の断片化が生じにくく、メモリ領域の断片化に起因するメモリ不足の発生を抑制することができる。   When the same processing is performed in the conventional memory management system to which the algorithm of the first adaptation method described with reference to FIG. 7 in the background art column is applied, the memory area of the memory 105 is stored as shown in FIG. Although fragmentation occurs, the memory area does not fragment in the memory 5 as described above. Therefore, in the memory management system 10 according to the present embodiment, fragmentation of the memory area is unlikely to occur, and occurrence of memory shortage due to fragmentation of the memory area can be suppressed.

また、特に情報処理装置や入出力装置、或いは画像処理装置などでデータ処理が行われる場合、ある特定の固定データサイズのデータが頻繁に処理される。例えば、固定データサイズの入出力バッファを介して転送され、処理されるデータは1キロバイトなどのように固定サイズであり、画像処理の場合に、画像の1ラインごとに処理されるデータも固定サイズである。   In particular, when data processing is performed by an information processing device, an input / output device, an image processing device, or the like, data having a specific fixed data size is frequently processed. For example, the data to be transferred and processed via an input / output buffer having a fixed data size is a fixed size such as 1 kilobyte, and in the case of image processing, the data processed for each line of the image is also a fixed size. It is.

そして、固定サイズでありながら互いにサイズの異なるデータについての割り付け要求が交互に(または交互ではなくても入り交じって)発生することにより、図3(a)や図7(a)に示されるような状態になることは、通常且つ頻繁に起こりうる。また、例えば、一連の画像処理が終了すれば全ラインのデータが不要となる場合等、ある固定サイズを有する複数のデータの割り付けが一斉に削除(解放)されることにより、図3(b)や図7(b)に示されるような状態になることも、通常且つ頻繁に起こりうる。従って、上述の情報処理装置等に本実施形態に係るメモリ管理システム10を適用すれば、メモリの断片化に起因するメモリ不足の発生を抑制することができるため、特に有用であるといえる。   Then, when allocation requests for data having different sizes but different sizes are generated alternately (or even if they are not alternating), as shown in FIG. 3A and FIG. 7A. It can happen normally and frequently. Further, for example, when a series of image processing is completed, the data of all lines becomes unnecessary, and the allocation of a plurality of data having a certain fixed size is deleted (released) all at once, so that FIG. It can also occur normally and frequently as shown in FIG. 7B. Therefore, if the memory management system 10 according to the present embodiment is applied to the above-described information processing apparatus or the like, it can be said that it is particularly useful because occurrence of a memory shortage due to memory fragmentation can be suppressed.

<<動作の説明:具体例2>>
更に、図4に示される別の具体例を用いて、最初適合法のアルゴリズムを適用した従来のメモリ管理システムと比較しながら、本実施形態に係るメモリ管理システム10の動作を説明する。図4は、図1における管理領域6に記憶される内容の一部及びメモリ5の使用状況の第2例を示す図であり、背景技術の欄で図8を用いて説明したメモリ領域の割り付け処理と同様の割り付け処理をメモリ管理システム10において実行させた場合のメモリの使用状況を示したものである。
<< Description of Operation: Specific Example 2 >>
Furthermore, the operation of the memory management system 10 according to the present embodiment will be described using another specific example shown in FIG. 4 while comparing with the conventional memory management system to which the algorithm of the first adaptation method is applied. FIG. 4 is a diagram showing a part of the contents stored in the management area 6 in FIG. 1 and a second example of the usage status of the memory 5, and the allocation of the memory area described with reference to FIG. 8 in the background art section The memory usage state when the allocation process similar to the process is executed in the memory management system 10 is shown.

図4(a)は、図8(a)と同様、当初、サイズが4キロバイト、20キロバイト、8キロバイト、32キロバイトの4つのデータ、及びその他のデータが本実施形態に係るメモリ管理システム10に備えれらるメモリ5に割り付け、その後それら4つのデータ、即ちサイズが4キロバイト、20キロバイト、8キロバイト、32キロバイトのデータの割り付けを削除(開放)した場合のメモリ5の使用状況を表している。図8(a)を用いて説明したメモリ105に対するものと同様、メモリ5に対する前記「4つのデータ」それぞれの割り付け前後にも、「他のデータ」の割り付けがなされており、それら「他のデータ」の割り付けは削除されていないものとする。それら「他のデータ」が割り付けられた領域は、図4(a)中、「使用中」と記載された部分に相当している。   4A, in the same manner as FIG. 8A, four data having a size of 4 kilobytes, 20 kilobytes, 8 kilobytes, 32 kilobytes, and other data are initially stored in the memory management system 10 according to the present embodiment. This shows the usage status of the memory 5 when it is allocated to the provided memory 5 and then the allocation of those four data, that is, data of the size of 4 kilobytes, 20 kilobytes, 8 kilobytes, and 32 kilobytes is deleted (released). . Similarly to the memory 105 described with reference to FIG. 8A, “other data” is allocated before and after the allocation of the “four data” to the memory 5. ”Is not deleted. The areas to which these “other data” are assigned correspond to the portions described as “in use” in FIG.

図4(b)は、図8(b)と同様、図4(a)の状態から、サイズが6キロバイトと32キロバイトのデータの割り付けを更に行った後のメモリ5の使用状況を表している。また、図4(a)及び図4(b)における管理領域6に記憶されている「基準サイズ」は16キロバイトとなっている。尚、図4(a)中、実線の矢印及び破線の矢印は、それぞれ更に割り付けを要求されたサイズが6キロバイト、32キロバイトのデータが格納されるべき空き領域を探査する順序を示している。   FIG. 4B shows the usage state of the memory 5 after further allocation of data of 6 kilobytes and 32 kilobytes in size from the state of FIG. 4A, as in FIG. 8B. . Further, the “reference size” stored in the management area 6 in FIGS. 4A and 4B is 16 kilobytes. In FIG. 4 (a), the solid line arrows and the broken line arrows indicate the order of searching for a free area in which data having a size of 6 kilobytes and 32 kilobytes which are requested to be allocated are stored.

図4(a)及び図4(b)の図中において、上方側がメモリ5の上位アドレス側、下方側が下位アドレス側を表しており、メモリ5の上端はそれぞれの最上位アドレス、下端はそれぞれの最下位アドレスに対応している。また、メモリ5において、当初割り付けられた「サイズが4キロバイト、20キロバイト、8キロバイト、32キロバイトの4つのデータ」は、サイズが4キロバイト、20キロバイト、8キロバイト、32キロバイトのデータの順に割り付けられたものとし、それぞれの割り付けが開放された後の空き領域を、メモリ105におけるものと同様(図8参照)、それぞれ空きA、空きB,空きC,空きDと言う。   4A and 4B, the upper side represents the upper address side of the memory 5, and the lower side represents the lower address side. The upper end of the memory 5 is the most significant address, and the lower end is the respective upper address. Corresponds to the lowest address. In addition, in the memory 5, the “4 pieces of data having a size of 4 kilobytes, 20 kilobytes, 8 kilobytes, and 32 kilobytes” that are initially allocated are assigned in the order of data having a size of 4 kilobytes, 20 kilobytes, 8 kilobytes, and 32 kilobytes. The empty areas after the respective allocations are released are referred to as empty A, empty B, empty C, and empty D, respectively, as in the memory 105 (see FIG. 8).

メモリ5に対して、当初割り付けられた「サイズが4キロバイト、20キロバイト、8キロバイト、32キロバイトの4つのデータ」のうち、サイズが4キロバイト及び8キロバイトのデータは、サイズが「基準サイズ」(16キロバイト)未満であるため、上述したように空き領域の探査方向は昇順となり(図2のステップS4参照)、上位アドレス側から下位アドレス側に向かってサイズが4キロバイトのデータ、サイズが8キロバイトのデータが、この順番で割り付けられる。   Of the “4 data of 4 kilobytes, 20 kilobytes, 8 kilobytes, and 32 kilobytes” initially allocated to the memory 5, the data of 4 kilobytes and 8 kilobytes has a size of “reference size” ( As described above, the exploration direction of the free area is ascending order (see step S4 in FIG. 2), and the data is 4 kilobytes in size from the upper address side to the lower address side, and the size is 8 kilobytes. Are allocated in this order.

当初割り付けられた「サイズが4キロバイト、20キロバイト、8キロバイト、32キロバイトの4つのデータ」のうち、サイズが20キロバイト及び32キロバイトのデータは、サイズが「基準サイズ」(16キロバイト)以上であるため、上述したように空き領域の探査方向は降順となり(図2のステップS3参照)、下位アドレス側から上位アドレス側に向かってサイズが20キロバイトのデータ、サイズが32キロバイトのデータが、この順番で割り付けられる。   Of the 4 data of 4 KB, 20 KB, 8 KB, and 32 KB allocated initially, the data of 20 KB and 32 KB are larger than the “standard size” (16 KB). Therefore, as described above, the exploration direction of the free area is in descending order (see step S3 in FIG. 2), and the data having a size of 20 kilobytes and the data having a size of 32 kilobytes are arranged in this order from the lower address side to the upper address side. It is assigned with.

そして、それらの当初割り付けられた「4つのデータ」に係る割り付けが開放された後は、図4(a)に示されるようなメモリの使用状況となる。即ち、上位アドレス側から、空きA、空きC、空きD、空きBの順番に空き領域が発生する。   Then, after the allocation according to the “4 data” allocated at the beginning is released, the memory usage state as shown in FIG. That is, empty areas are generated in the order of empty A, empty C, empty D, and empty B from the higher address side.

図4(a)の状態から更にサイズが6キロバイトのデータの割り付けを行う際は、そのサイズが「基準サイズ」(16キロバイト)未満であるため、上述したように空き領域の探査方向は昇順となり(図2のステップS4参照)、以下のように、上位アドレス側から空き領域が探査される(図4(a)中の実線の矢印を参照)。
(ステップ1):空きAのサイズ(4キロバイト)と、6キロバイトが比較されるが、割り付けできないので、次の空き領域を検索する。
(ステップ2):空きCのサイズ(8キロバイト)に、6キロバイトのサイズのメモリ領域を確保することができるため、空きCを選択して割り付ける。
When data having a size of 6 kilobytes is further allocated from the state of FIG. 4A, since the size is less than the “reference size” (16 kilobytes), the search direction of the free area is ascending order as described above. (See step S4 in FIG. 2) As shown below, a free area is searched from the higher address side (see the solid line arrow in FIG. 4A).
(Step 1): The size of free space A (4 kilobytes) is compared with 6 kilobytes, but cannot be allocated, so the next free space is searched.
(Step 2): Since a memory area of 6 kilobytes can be secured in the size of free C (8 kilobytes), free C is selected and allocated.

このように、サイズが6キロバイトのデータを更に割り付けるに際して、最初適合法のアルゴリズムを適用したメモリ管理システムにおいては、上述したように(図8(b)参照)、サイズが20キロバイトの空きBを選択したのに対し、本実施形態に係るメモリ管理システム10においては、割り付けを要求されたデータのサイズ(6キロバイト)と空き領域のサイズとの差がより小さい空きCを選択することとなる。   In this way, when further allocating data having a size of 6 kilobytes, in the memory management system to which the algorithm of the first adaptation method is applied, as described above (see FIG. 8B), the free space B having a size of 20 kilobytes is allocated. On the other hand, in the memory management system 10 according to the present embodiment, the free space C having a smaller difference between the size of the data requested to be allocated (6 kilobytes) and the free space size is selected.

これは、「基準サイズ」(16キロバイト)未満のサイズを有するデータの割り付けは最上位アドレスから降順に、「基準サイズ」以上のサイズを有するデータの割り付けは最下位アドレスから昇順に、空き領域を探査することにより、上位アドレス側には「基準サイズ」未満のサイズを有する比較的小さな空き領域が、下位アドレス側には「基準サイズ」以上のサイズを有する比較的大きな空き領域が集まりやすくなっていることに起因している。   This is because the allocation of data having a size smaller than the “reference size” (16 kilobytes) is performed in descending order from the highest address, and the allocation of data having a size larger than the “reference size” is performed in ascending order from the lowest address. By exploring, a relatively small free area having a size smaller than the “reference size” is easily gathered on the upper address side, and a relatively large free area having a size larger than the “reference size” is easily gathered on the lower address side. This is due to the fact that

そして、図4(b)に示すように、空きCにサイズが6キロバイトのデータを割り付けることで残存した新たな空き領域(空きC’)のサイズは、8キロバイトから6キロバイトを差し引いた2キロバイトとなるが、空きBは、図8(b)の空きB’(サイズが14キロバイト)と異なり20キロバイトのサイズを維持しているため、次回、サイズが20キロバイトのデータについての割り付け要求が発生しても、空きBにそのデータを格納することができる。従って、本実施形態に係るメモリ管理システム10は、メモリ不足が発生しにくく、メモリの使用効率が良いといえる。   As shown in FIG. 4B, the size of the new free area (free C ′) remaining by allocating 6 kilobytes of data to the free C is 2 kilobytes obtained by subtracting 6 kilobytes from 8 kilobytes. However, the free space B is maintained at a size of 20 kilobytes, unlike the free space B ′ (size is 14 kilobytes) in FIG. 8B, so an allocation request for the next data size of 20 kilobytes is generated. Even so, the data can be stored in the space B. Therefore, it can be said that the memory management system 10 according to the present embodiment is less likely to cause a memory shortage and the use efficiency of the memory is good.

また、図4(a)の状態から更にサイズが32キロバイトのデータの割り付けを行う際は、そのサイズが「基準サイズ」(16キロバイト)以上であるため、上述したように空き領域の探査方向は降順となり(図2のステップS3参照)、以下のように、下位アドレス側から空き領域が探査される(図中、破線の矢印参照)。
(ステップ1):空きBのサイズ(20キロバイト)と、32キロバイトが比較されるが、割り付けできないので、次の空き領域を検索する。
(ステップ2):空きDのサイズ(32キロバイト)に、32キロバイトのサイズのメモリ領域を確保することができるため、空きDを選択して割り付ける。
In addition, when allocating data having a size of 32 kilobytes further from the state of FIG. 4A, the size is equal to or larger than the “reference size” (16 kilobytes). In descending order (see step S3 in FIG. 2), a free area is searched from the lower address side as follows (see broken arrow in the figure).
(Step 1): The size of the free space B (20 kilobytes) is compared with 32 kilobytes, but cannot be allocated, so the next free space is searched.
(Step 2): Since a memory area having a size of 32 kilobytes can be secured in the size of the free space D (32 kilobytes), the free space D is selected and allocated.

このように、サイズが32キロバイトのデータを更に割り付けるに際して、背景技術の欄で図8を用いて説明した最初適合法のアルゴリズムを適用した従来のメモリ管理システムにおいては、4つの空き領域全てを検索する必要があったが、メモリ管理システム10においては、2つの空き領域(空きB、空きD)を検索するだけで割る付けるべき空き領域の探査が完了している。   As described above, in the conventional memory management system to which the algorithm of the first adaptation method described with reference to FIG. 8 in the background art column is applied when further allocating data having a size of 32 kilobytes, all four free areas are searched. However, in the memory management system 10, the search for the free area to be allocated has been completed only by searching for two free areas (free B and free D).

これも、「基準サイズ」(16キロバイト)未満のサイズを有するデータの割り付けは最上位アドレスから降順に、「基準サイズ」以上のサイズを有するデータの割り付けは最下位アドレスから昇順に、空き領域を探査することにより、上位アドレス側には「基準サイズ」未満のサイズを有する比較的小さな空き領域が、下位アドレス側には「基準サイズ」以上のサイズを有する比較的大きな空き領域が集まりやすくなっていることに起因している。   This also means that the allocation of data having a size smaller than the “reference size” (16 kilobytes) is performed in descending order from the highest address, and the allocation of data having a size greater than the “reference size” is performed in ascending order from the lowest address. By exploring, a relatively small free area having a size smaller than the “reference size” is easily gathered on the upper address side, and a relatively large free area having a size larger than the “reference size” is easily gathered on the lower address side. This is due to the fact that

つまり、「基準サイズ」以上のサイズのデータを新たに割り付ける場合は、「基準サイズ」以上のサイズを有する比較的大きな空き領域が集まっている上位アドレス側を優先的に探査することとなるため、「基準サイズ」未満のサイズの空き領域が集まりやすい上位アドレス側の空き領域を無駄に探査することが抑制されて、より高速に割り付けるべき空き領域の探査が完了するわけである。   In other words, when newly allocating data with a size greater than or equal to the “reference size”, the higher address side where a relatively large free area having a size greater than or equal to the “reference size” is gathered is preferentially searched. Searching for empty areas on the higher address side where empty areas with a size smaller than the “reference size” tend to gather is suppressed, and search for empty areas to be allocated at higher speed is completed.

従って、本実施形態に係るメモリ管理システム10は、メモリ領域の断片化の発生を抑制すると共に、高速な割り付け処理を行うことができると言える。   Therefore, it can be said that the memory management system 10 according to the present embodiment can suppress the occurrence of fragmentation of the memory area and perform high-speed allocation processing.

また、最初適合法のアルゴリズムを採用した場合は、上述したようにメモリ領域の上位アドレス側(先頭付近)の利用頻度が他の部分(下位アドレス側等)に比べて高くなるため、メモリ領域の先頭付近にメモリ領域の断片化が頻繁に発生することとなるが、本実施形態に係るメモリ管理システム10においては、メモリ領域の上位アドレス側と下位アドレス側の利用頻度の偏りが軽減されているため、メモリ領域の断片化の発生が抑制されるといえる。   In addition, when the algorithm of the first adaptation method is adopted, the use frequency of the upper address side (near the top) of the memory area becomes higher than that of other parts (lower address side etc.) as described above. Although fragmentation of the memory area frequently occurs in the vicinity of the head, in the memory management system 10 according to the present embodiment, the deviation in the usage frequency between the upper address side and the lower address side of the memory area is reduced. Therefore, it can be said that the occurrence of fragmentation of the memory area is suppressed.

<<動作の説明:具体例3>>
更に、図5に示される別の具体例を用いて、最初適合法のアルゴリズムを適用した従来のメモリ管理システムと比較しながら、本実施形態に係るメモリ管理システム10の動作を説明する。図5は、図1における管理領域6に記憶される内容の一部及びメモリ5の使用状況の第3例を示す図であり、背景技術の欄で図9を用いて説明したメモリ領域の割り付け処理と同様の割り付け処理をメモリ管理システム10において実行させた場合のメモリの使用状況を示したものである。
<< Description of Operation: Specific Example 3 >>
Furthermore, the operation of the memory management system 10 according to the present embodiment will be described using another specific example shown in FIG. 5 while comparing with the conventional memory management system to which the algorithm of the first adaptation method is applied. FIG. 5 is a diagram showing a part of the contents stored in the management area 6 in FIG. 1 and a third example of the usage status of the memory 5, and the allocation of the memory area described with reference to FIG. 9 in the background art section The memory usage state when the allocation process similar to the process is executed in the memory management system 10 is shown.

図5(a)は、メモリ5に対して全領域が未使用(空き)の状態から、複数のデータの割り付けを行った後のメモリ5の使用状況を表したものである。この複数のデータは、図9(a)を用い背景技術の欄にて説明した「メモリ105に対して全領域が未使用の状態から割り付けた複数のデータ」と全く同じものとし(図9(a)参照)、その割り付けられた複数のデータの中には、図5(a)及び図5(b)に示す管理領域6に記憶されている「基準サイズ」(16キロバイト)以上のサイズを有するデータと、「基準サイズ」未満のサイズを有するデータが含まれているものとする。また、その割り付け後もメモリ5には空き領域が残存しているものとする。   FIG. 5A shows the usage state of the memory 5 after a plurality of data are allocated from the state in which the entire area is unused (free) with respect to the memory 5. The plurality of data is exactly the same as the “plurality of data allocated to the memory 105 from an unused state” described in the background art section with reference to FIG. a)), among the plurality of allocated data, a size equal to or larger than the “reference size” (16 kilobytes) stored in the management area 6 shown in FIGS. 5A and 5B. And data having a size smaller than the “reference size”. Further, it is assumed that an empty area remains in the memory 5 even after the allocation.

図5(a)及び図5(b)の図中において、上方側がメモリ5の上位アドレス側、下方側が下位アドレス側を表しており、メモリ5の上端はそれぞれの最上位アドレス、下端はそれぞれの最下位アドレスに対応している。   5A and 5B, the upper side represents the upper address side of the memory 5 and the lower side represents the lower address side. The upper end of the memory 5 is the most significant address and the lower end is the respective upper address. Corresponds to the lowest address.

本実施形態に係るメモリ管理システム10においては、上述したように、割り付けられるデータのサイズが「基準サイズ」未満であれば空き領域を最上位アドレスから昇順に(図2のステップS4参照)、「基準サイズ」以上であれば空き領域を最下位アドレスから降順に(図2のステップS3参照)探査方向を変えるため、図5(a)に示すように、メモリ5の上位アドレス側と下位アドレス側の2つに分離してデータが割り付けられて「使用中」となっており、その分離した使用中の領域の間が空き領域(図中、「空き」と表示)となっている。   In the memory management system 10 according to the present embodiment, as described above, if the size of the allocated data is less than the “reference size”, the free areas are arranged in ascending order from the highest address (see step S4 in FIG. 2), “ If the size is equal to or larger than the “reference size”, the search direction is changed in descending order from the lowest address (see step S3 in FIG. 2), so that the upper address side and the lower address side of the memory 5 are changed as shown in FIG. The data is allocated to the two areas and becomes “in use”, and a space between the separated areas in use is a free area (indicated as “free” in the figure).

図5(b)は、図9(b)と同様、図5(a)の状態から、新たにサイズがそれぞれ8キロバイト、20キロバイト、32キロバイトのデータS、データT、データUに対する割り付けを、この順番で行った場合のメモリ5の使用状況を表したものである。図5(b)に示すように、データSのサイズ(8キロバイト)は「基準サイズ」(16キロバイト)未満であるため、データSはメモリ5の上位アドレス側にある「使用中」の領域の下位アドレス側に連続して割り付けられ、データTのサイズ(20キロバイト)及びデータUのサイズ(30キロバイト)は共に「基準サイズ」(16キロバイト)以上であるため、メモリ5の下位アドレス側にある「使用中」の領域の上位アドレス側に連続し、且つメモリアドレスの降順にデータT、データUが割り付けられる。   FIG. 5 (b) is similar to FIG. 9 (b). From the state of FIG. 5 (a), the allocation to the data S, data T, and data U having new sizes of 8 kilobytes, 20 kilobytes, and 32 kilobytes, respectively, This shows the usage status of the memory 5 when this is done in this order. As shown in FIG. 5B, since the size of the data S (8 kilobytes) is less than the “reference size” (16 kilobytes), the data S is stored in the “in use” area on the upper address side of the memory 5. Since the data T size (20 kilobytes) and the data U size (30 kilobytes) are both equal to or larger than the “reference size” (16 kilobytes), they are on the lower address side of the memory 5. Data T and data U are allocated in the descending order of the memory addresses continuously to the upper address side of the “in use” area.

次に、図5(b)の状態から、データS、データT、データUのいずれか1つを削除(開放)した場合のメモリ領域の断片化の発生の有無を、最初適合法のアルゴリズムを適用した従来のメモリ管理システムと比較しながら(図9(b)参照)、検討する。   Next, from the state of FIG. 5B, whether or not the memory area is fragmented when any one of the data S, data T, and data U is deleted (released) A comparison will be made with the conventional memory management system applied (see FIG. 9B).

まず、図9(b)に示す状態にあるメモリ105からデータUの割り付けのみを削除(開放)しても、データUの割り付けられた領域は既に存在している空き領域と隣接しているため、メモリ領域の断片化は生じない。図5(b)に示す状態にあるメモリ5からデータUの割り付けのみを削除(開放)しても、同様のことが言える。   First, even if only the allocation of the data U is deleted (released) from the memory 105 in the state shown in FIG. 9B, the allocated area of the data U is adjacent to the already existing empty area. The memory area is not fragmented. The same can be said even if only the allocation of data U is deleted (released) from the memory 5 in the state shown in FIG.

また、図9(b)に示す状態にあるメモリ105からデータTの割り付けのみを削除(開放)すると、データTの割り付けられた領域は、データSとデータUの割り付けられた領域の間にあるため、メモリ領域の断片化が生じ、図5(b)に示す状態にあるメモリ5からデータTの割り付けのみを削除(開放)した場合も、データTの割り付けられた領域は、データUの割り付けられた領域と既にメモリ5の下位アドレス側にある使用中の領域の間にあるため、メモリ領域の断片化が生じる。   If only the allocation of data T is deleted (released) from the memory 105 in the state shown in FIG. 9B, the area to which data T is allocated is between the areas to which data S and data U are allocated. Therefore, even when the memory area is fragmented and only the allocation of the data T is deleted (released) from the memory 5 in the state shown in FIG. 5B, the area to which the data T is allocated is allocated to the data U. The memory area is fragmented because it is between the area that has been allocated and the area that is already in use on the lower address side of the memory 5.

ところが、図9(b)に示す状態にあるメモリ105からデータSの割り付けのみを削除(開放)すると、データSの割り付けられた領域は既に存在している空き領域に隣接していないため、メモリ領域の断片化が生じるのに対し、図5(b)に示す状態にあるメモリ5からデータSの割り付けのみを削除(開放)しても、データSが割り付けられた領域は既に存在している空き領域に隣接しているため、削除されるデータSが割り付けられていた領域は既にある空き領域と併合されることとなって、メモリ領域の断片化が生じない。   However, if only the allocation of the data S is deleted (released) from the memory 105 in the state shown in FIG. 9B, the area to which the data S is allocated is not adjacent to an already existing free area. Although the fragmentation of the area occurs, even if only the allocation of the data S is deleted (released) from the memory 5 in the state shown in FIG. 5B, the area to which the data S is allocated already exists. Since it is adjacent to the empty area, the area where the data S to be deleted is allocated is merged with the existing empty area, and the memory area is not fragmented.

このように、メモリ105及びメモリ5に対して、同様のメモリ領域の割り付け、削除を行っても、メモリ5がメモリ105に比べてメモリ領域の断片化が生じにくい。これは、本実施形態に係るメモリ管理システム10においては、割り付けられるデータのサイズに応じて空き領域の探査方向の昇順、降順が切り換えられるため、空き領域が中央に集まりやすくなるためである。   As described above, even when the same memory area is allocated to and deleted from the memory 105 and the memory 5, the memory area is less likely to be fragmented in the memory 5 than in the memory 105. This is because in the memory management system 10 according to the present embodiment, the ascending order and descending order of the exploration direction of the free area are switched according to the size of the allocated data, so that the free area is easily gathered in the center.

<<メモリ不足となった時の処理(ステップS8)>>
次に、管理領域6に記憶される「基準サイズ」が、割り付け要求元であるプログラム3やOS2にとって最適な値に自動的に更新される様子を、図6を用いて説明する。図6は、管理領域6に記憶される「基準サイズ」が変更されて、メモリ5の使用状況が変化していく様子を表した図である。
<< Process when memory is insufficient (step S8) >>
Next, how the “reference size” stored in the management area 6 is automatically updated to an optimum value for the program 3 or OS 2 that is the allocation request source will be described with reference to FIG. FIG. 6 is a diagram showing how the usage status of the memory 5 changes as the “reference size” stored in the management area 6 is changed.

図6(a)、図6(b)、図6(c)、図6(d)、図6(e)、図6(f)の全ての図中において、上方側がメモリ105またはメモリ5の上位アドレス側、下方側が下位アドレス側を表しており、メモリ105、メモリ5の上端はそれぞれの最上位アドレス、下端はそれぞれの最下位アドレスに対応している。また、図6(a)〜(f)の全ての図中のメモリ5は、データの記憶内容こそ異なれど同一のメモリであって、その全記憶容量は32キロバイトである。   6A, FIG. 6B, FIG. 6C, FIG. 6D, FIG. 6E, and FIG. 6F, the upper side is the memory 105 or the memory 5. The upper address side and the lower side represent the lower address side, and the upper ends of the memory 105 and the memory 5 correspond to the most significant address, and the lower end corresponds to the least significant address. 6A to 6F are the same memory with different data storage contents, and the total storage capacity is 32 kilobytes.

図6(a)は、メモリ5に対して、全領域が未使用(空き)の状態から、サイズがそれぞれ2キロバイト、14キロバイト、4キロバイト、10キロバイトのデータL、データM、データN、データOの割り付けを、この順番に行った後のメモリ5の使用状況を表した図である。また、これらのデータの割り付けを行う際、「基準サイズ」は、16キロバイトとなっていたものとする。そうすると、データL、データM、データN、データOの全てのサイズは「基準サイズ」未満であるので、上述したように空き領域の探査方向は全て昇順となり(図2のステップS4参照)、図6(a)に示すように、最上位アドレスからデータL、データM、データN、データOの順番に連続してメモリ領域が割り付けられる。また、データOが割り付けられた領域の下位アドレス側には、メモリ5の全記憶容量(32キロバイト)から、データL、データM、データN、データOを割り付けた分を差し引いた6キロバイトのサイズの空き領域が新たに生成される。   FIG. 6A shows data L, data M, data N, and data having a size of 2 kilobytes, 14 kilobytes, 4 kilobytes, and 10 kilobytes from the state in which all areas are unused (free) with respect to the memory 5. It is a figure showing the use condition of the memory 5 after performing the allocation of O in this order. Also, when assigning these data, the “reference size” is assumed to be 16 kilobytes. Then, since all the sizes of the data L, data M, data N, and data O are less than the “reference size”, the search directions of the empty areas are all in ascending order as described above (see step S4 in FIG. 2). As shown in FIG. 6A, the memory areas are continuously allocated in the order of data L, data M, data N, and data O from the most significant address. Further, on the lower address side of the area to which data O is allocated, the size of 6 kilobytes is obtained by subtracting the data L, data M, data N, and data O allocation from the total storage capacity (32 kilobytes) of the memory 5. Free space is newly generated.

この図6(a)に示すような「基準サイズ」(16キロバイト)は、メモリ5の使用効率上、適切な値になっているとはいえない。なぜなら、割り付けられた全てのデータのサイズが「基準サイズ」未満であるため、常に割り付け領域の探査方向が昇順となってしまい、最初適合法のアルゴリズムを用いた場合と同じメモリ領域の割り付けを行ってしまうためである。   The “reference size” (16 kilobytes) as shown in FIG. 6A cannot be said to be an appropriate value in terms of use efficiency of the memory 5. Because the size of all allocated data is less than the “reference size”, the search direction of the allocation area is always in ascending order, and the same memory area allocation as when using the first adaptation algorithm is performed. It is because it ends up.

図6(b)は、メモリ5及び管理領域6が図6(a)の状態にある場合に、新たにデータP(サイズが8キロバイト)の割り付け要求が発生した時のメモリ5の使用状況及び「基準サイズ」の値を表した図である。上述したように、メモリ5にはサイズが6キロバイトの空き領域が1つ存在しているだけなので、サイズが8キロバイトのデータPを割り付けることができない。この新たな割り付け要求に対して、空き領域不足のため割り付けができない状態、換言すれば、新たな割り付けを要求されたデータのサイズ以上のサイズを有する空き領域がない状態を、以下「メモリオーバー」という。   FIG. 6B shows the usage status of the memory 5 when the memory 5 and the management area 6 are in the state shown in FIG. 6A, and an allocation request for data P (size is 8 kilobytes) is newly generated. It is a figure showing the value of "reference size." As described above, since there is only one free area having a size of 6 kilobytes in the memory 5, data P having a size of 8 kilobytes cannot be allocated. In response to this new allocation request, a state in which allocation is not possible due to insufficient free space, in other words, a state in which there is no free space having a size larger than the size of the data requested for new allocation, is referred to as “memory over”. That's it.

この状態は、上述のステップS7(図2)の判定結果が肯定である状態であるので、メモリ管理システム10は、上述のステップS8(図2)の処理を行うこととなる。即ち、メモリ管理手段4がCPU1に対して「割り付け不可能」の信号を伝達する等の割り付け不可能に係わるエラー処理を行うとともに、「基準サイズ」の値を新たな割り付けを要求されたデータPのサイズ(8キロバイト)の値で書き換える。従って、図6(b)に示すように、「基準サイズ」が8キロバイトに変更される。   Since this state is a state in which the determination result in step S7 (FIG. 2) is affirmative, the memory management system 10 performs the process in step S8 (FIG. 2). In other words, the memory management means 4 performs error processing related to the inability to allocate such as transmitting a “not assignable” signal to the CPU 1 and sets the value of the “reference size” to the data P requested to be newly assigned. Rewrite with the value of size (8 kilobytes). Therefore, as shown in FIG. 6B, the “reference size” is changed to 8 kilobytes.

ところで、割り付け要求元であるプログラム3やOS2は、1種類や2種類でなく、時には数十種類に及ぶような様々なサイズの領域について、メモリの割り付けを要求するのが通常であるため、この変更された「基準サイズ」(8キロバイト)は、今後発生するであろう割り付け要求に係るデータのサイズの最小値または最大値となる可能性は低い。逆に言うと、今後、割り付け要求元であるプログラム3やOS2は、この変更された「基準サイズ」以上のサイズを有するデータの割り付け要求と、このサイズ未満のサイズを有するデータの割り付け要求とを混在して行う可能性が高いと言える。   By the way, since the allocation request source program 3 and OS 2 normally request memory allocation for areas of various sizes such as one or two, sometimes several tens of types. The changed “reference size” (8 kilobytes) is unlikely to be the minimum value or the maximum value of the data size related to the allocation request that will occur in the future. Conversely, in the future, the program 3 and OS 2 that are allocation request sources will make an allocation request for data having a size larger than the changed “reference size” and an allocation request for data having a size less than this size. It can be said that there is a high possibility that it will be performed in a mixed manner.

従って、この「基準サイズ」の変更があった後は、割り付けを要求されたデータのサイズに応じて空き領域の探査方向を切り換えるというメモリ管理システム10の有する特徴が、十分に発揮されるようになる。   Therefore, after the “reference size” is changed, the memory management system 10 has a feature that the search direction of the free area is switched according to the size of the data requested to be allocated. Become.

つまり、「メモリオーバー」の契機となった割り付けを要求されたデータのサイズで、「基準サイズ」を書き換えることにより、「基準サイズ」は割り付け要求元のプログラム3やOS2にとって、より適した値に変更されたことになる。   In other words, by rewriting the “reference size” with the size of the data requested to be allocated that triggered the “memory over”, the “reference size” becomes a more suitable value for the allocation request source program 3 or OS 2. It has been changed.

また、CPU1が上記「割り付け不可能」の信号を受けると、CPU1は割り付け要求元であるプログラム3またはOS2に「割り付け不可能」に関する情報を伝え、割り付け要求元は、既にメモリ5に割り付けられたデータのうち、削除しても良いデータがないかどうかを判断する。ここで、削除しても良いデータが一切ない場合は、データPを割り付けることができない訳であるが、今、データOの割り付けを削除(開放)しても良いと判断したとする。   Further, when the CPU 1 receives the “allocation impossible” signal, the CPU 1 informs the program 3 or OS 2 which is the allocation request source, information regarding “allocation impossible”, and the allocation request source has already been allocated to the memory 5. It is determined whether there is any data that can be deleted. Here, if there is no data that can be deleted, the data P cannot be allocated, but it is now determined that the allocation of the data O may be deleted (released).

図6(c)は、図6(b)の状態から、データOの割り付けを削除した時のメモリ5の使用状況及び「基準サイズ」の値を表した図である。図6(b)の状態より存在していたサイズが6キロバイトの空き領域とデータOの割り付けられていた領域が併合したサイズが16キロバイトの空き領域が、データNの割り付けられた領域に連続した下位アドレス側の領域に新たに生成される。このサイズが16キロバイトの新たな空き領域には、サイズが8キロバイトのデータPを格納可能である。   FIG. 6C is a diagram showing the usage status of the memory 5 and the value of “reference size” when the allocation of the data O is deleted from the state of FIG. From the state of FIG. 6B, a free area of 6 kilobytes and an area where data O is allocated merged into the area where data N is allocated. It is newly generated in the area on the lower address side. Data P having a size of 8 kilobytes can be stored in a new free area having a size of 16 kilobytes.

そして、メモリ5及び管理領域6が図6(c)の状態にある場合に、データPを割り付けた時のメモリ5の使用状況及び「基準サイズ」の値を表した図が、図6(d)である。データPのサイズ(8キロバイト)は、「基準サイズ」(8キロバイト)以上であるため、空き領域は最下位アドレスより降順に探査され、図6(d)に示すように、データPは図6(c)の状態で存在していた空き領域(サイズが16キロバイト)中の下位アドレス側から割り付けられる。そして、データPの割り付けられた領域に連続した上位アドレス側の領域には、サイズが8キロバイトの空き領域が残存する。   Then, when the memory 5 and the management area 6 are in the state of FIG. 6C, a diagram showing the usage status of the memory 5 and the value of “reference size” when the data P is allocated is shown in FIG. ). Since the size of the data P (8 kilobytes) is equal to or larger than the “reference size” (8 kilobytes), the free area is searched in descending order from the lowest address, and as shown in FIG. It is allocated from the lower address side in the free area (size is 16 kilobytes) that existed in the state of (c). Then, an empty area having a size of 8 kilobytes remains in the area on the higher address side that is continuous with the area to which the data P is allocated.

図6(e)は、図6(d)の状態から、更にデータM及びデータNの割り付けを削除した時のメモリ5の使用状況及び「基準サイズ」の値を表した図である。このデータM及びデータNの削除に関する指令もプログラム3またはOS2が行う。これにより、図6(d)の状態で存在していた空き領域(サイズが8キロバイト)と、削除されるデータM及びデータNの割り付けられていた領域が併合することにより、データLの割り付けられた領域とデータPの割り付けられた領域の間に、サイズが26キロバイトの空き領域が新たに生成される。   FIG. 6E is a diagram showing the usage state of the memory 5 and the value of “reference size” when the allocation of the data M and the data N is further deleted from the state of FIG. The program 3 or the OS 2 also issues a command for deleting the data M and data N. As a result, the free area (size is 8 kilobytes) that existed in the state of FIG. 6D and the area where the data M and the data N to be deleted are merged are allocated to the data L. A free area having a size of 26 kilobytes is newly generated between the allocated area and the area to which the data P is allocated.

図6(f)は、図6(e)の状態から、データQ(サイズが8キロバイト)及びデータR(サイズが4キロバイト)の割り付けを新たに行った時のメモリ5の使用状況及び「基準サイズ」の値を表した図である。データQは「基準サイズ」(8キロバイト)以上であるため空き領域は降順に探査される。従って、データQは、データPの割り付けられた領域に連続した上位アドレス側の領域に割り付けられる。データRは「基準サイズ」(8キロバイト)未満であるため空き領域は昇順に探査される。従って、データRは、データLの割り付けられた領域に連続した下位アドレス側の領域に割り付けられる。そして、データQとデータRを割り付けたことにより、データQが割り付けられた領域とデータRが割り付けられた領域の間に、サイズが10キロバイトの空き領域が残存する。   FIG. 6F shows the usage status of the memory 5 and the “reference” when the data Q (size is 8 kilobytes) and the data R (size is 4 kilobytes) are newly allocated from the state of FIG. It is a figure showing the value of "size". Since the data Q is equal to or larger than the “reference size” (8 kilobytes), the free area is searched in descending order. Therefore, the data Q is allocated to the area on the higher address side that is continuous with the area to which the data P is allocated. Since the data R is less than the “reference size” (8 kilobytes), the free area is searched in ascending order. Therefore, the data R is allocated to the area on the lower address side that is continuous with the area to which the data L is allocated. As a result of allocating data Q and data R, a free area having a size of 10 kilobytes remains between the area where data Q is allocated and the area where data R is allocated.

この図6(f)に示すメモリ5の使用状況は、図3や図4を用いて説明してきたように、「基準サイズ」以上のサイズのデータは下位アドレス側よりに、「基準サイズ」未満のサイズのデータは上位アドレス側よりにまとまって割り付けられた状況になっている。これは、「メモリオーバー」となった時、「基準サイズ」をその新たな割り付けを要求されたデータのサイズで書き換えたことに起因している。   The usage status of the memory 5 shown in FIG. 6F is less than the “reference size” for data having a size larger than the “reference size” from the lower address side, as described with reference to FIGS. The data of the size is allocated in a group from the upper address side. This is because, when “memory is over”, the “reference size” is rewritten with the data size requested for the new allocation.

そして、図6(f)のように、「基準サイズ」以上のサイズのデータを下位アドレス側に、「基準サイズ」未満のサイズのデータを上位アドレス側にまとまって割り付ければ、メモリ領域の断片化の発生を抑制しつつも、高速な割り付け処理が実現できることは、上述してきたとおりである。   Then, as shown in FIG. 6F, if data having a size greater than or equal to the “reference size” is allocated to the lower address side and data having a size less than the “reference size” is allocated to the upper address side, a fragment of the memory area is allocated. As described above, it is possible to realize a high-speed allocation process while suppressing the occurrence of conversion.

また、「メモリオーバー」を契機として「基準サイズ」が割り付け要求元であるプログラム3等にとって、より適切でない値に変更される場合もありうる。しかし、「メモリオーバー」や、不要な割り付け領域の削除命令、新たな割り付け要求は頻繁に発生するため、この「基準サイズ」が適切でない状態は直ぐに解消される。即ち、「基準サイズ」は、割り付け要求元であるプログラム3等にとって適切な(統計的に最適な)値に自動的に更新されていくといえる。   In addition, the “reference size” may be changed to a value that is not appropriate for the program 3 or the like that is the allocation request source in response to “memory over”. However, since “memory over”, an unnecessary allocation area deletion command, and a new allocation request frequently occur, the state where the “reference size” is not appropriate is solved immediately. That is, it can be said that the “reference size” is automatically updated to a value (statistically optimal) appropriate for the program 3 or the like that is the allocation request source.

<<その他>>
また、本発明を画像形成装置等にて実施する場合、装置の種類によってメモリの割り付けを要求されたデータのサイズは装置の設計段階で予め決まっているものである。例えば、割り付けを要求されたデータのサイズの最大値(最大のサイズ)が128キロバイト、最小値(最小のサイズ)が1キロバイトといった具合である。従って、割り付けを要求されたデータのサイズに応じて空き領域の探査方向を切り換えるという本発明の有する特徴が当初より発揮されるように、「基準サイズ」の初期値を、前記最大値より小さく、且つ前記最小値より大きい値に設定してもよい。
<< Other >>
When the present invention is implemented in an image forming apparatus or the like, the size of data requested to be allocated a memory depending on the type of apparatus is determined in advance in the apparatus design stage. For example, the maximum value (maximum size) of the data requested to be allocated is 128 kilobytes, the minimum value (minimum size) is 1 kilobyte, and so on. Therefore, the initial value of the “reference size” is smaller than the maximum value so that the feature of the present invention that the search direction of the free area is switched according to the size of the data requested to be allocated from the beginning, Further, it may be set to a value larger than the minimum value.

尚、上述した実施例においては、割り付けを要求されたデータのサイズが「基準サイズ」以上であれば空き領域の探査方向を降順(図2のステップS3)、「基準サイズ」未満であれば空き領域の探査方向を昇順(図2のステップS4)とする例を挙げたが、勿論、図2におけるステップS2の記号「≧」を「>」、「≦」、「<」の何れに変えても良い。何れにしても、上述した本発明の有する効果は実現されるからである。   In the above-described embodiment, if the size of the data requested to be allocated is equal to or larger than the “reference size”, the search direction of the free area is in descending order (step S3 in FIG. 2), and if the size is less than the “reference size”, the empty space is available. The example in which the search direction of the region is set in ascending order (step S4 in FIG. 2) is given. Of course, the symbol “≧” in step S2 in FIG. 2 is changed to any of “>”, “≦”, and “<”. Also good. In any case, the above-described effects of the present invention are realized.

即ち、割り付けを要求されたデータのサイズが「基準サイズ」よりおおきれば空き領域の探査方向を降順、「基準サイズ」以下であれば空き領域の探査方向を昇順としても良いし(「>」に相当)、割り付けを要求されたデータのサイズが「基準サイズ」よりおおきれば空き領域の探査方向を昇順、「基準サイズ」以下であれば空き領域の探査方向を降順としても良い(「≦」に相当)。更に、割り付けを要求されたデータのサイズが「基準サイズ」以上であれば空き領域の探査方向を昇順、「基準サイズ」未満であれば空き領域の探査方向を降順としても良い(「<」に相当)。   That is, if the size of the data requested to be allocated is larger than the “reference size”, the exploration direction of the free area may be in descending order, and if it is less than the “reference size”, the exploration direction of the free area may be ascending order (“>”). If the size of the data requested to be allocated is larger than the “reference size”, the exploration direction of the free area may be ascending order, and if the size is less than the “reference size”, the exploration direction of the free area may be descending order (“≦≦ ”). Further, if the size of the data requested to be allocated is equal to or larger than the “reference size”, the search direction of the free area may be ascending order, and if the size is less than the “reference size”, the search direction of the free area may be set to the descending order (“<”). Equivalent).

また、これまで、割り付けを要求されたデータのサイズを8キロバイト、メモリ5の記憶容量を32キロバイト、「基準サイズ」の初期値を16キロバイト等、具体的な数値を例に挙げて説明したが、本発明はこうした数値に限定されないことはいうまでもない。   In the above description, the data requested to be allocated has been described using specific numerical values such as 8 kilobytes, the storage capacity of the memory 5 as 32 kilobytes, and the initial value of “reference size” as 16 kilobytes. Needless to say, the present invention is not limited to such numerical values.

上述した通り、本発明に係るメモリ管理システムによれば、メモリ領域の断片化を抑制しつつも、高速な割り付け処理を行うことができる。   As described above, according to the memory management system of the present invention, high-speed allocation processing can be performed while suppressing fragmentation of the memory area.

本発明の実施の形態に係るメモリ管理システム10の構成図である。1 is a configuration diagram of a memory management system 10 according to an embodiment of the present invention. 図1におけるメモリ管理システム10の動作を説明するためのフローチャートである。3 is a flowchart for explaining the operation of the memory management system 10 in FIG. 1. 図1における管理領域6に記憶される内容の一部及びメモリ5の使用状況の第1例を示す図である。It is a figure which shows the 1st example of the usage condition of a part of content stored in the management area | region 6 in FIG. 図1における管理領域6に記憶される内容の一部及びメモリ5の使用状況の第2例を示す図である。It is a figure which shows the 2nd example of the usage condition of a part of content memorize | stored in the management area | region 6 in FIG. 図1における管理領域6に記憶される内容の一部及びメモリ5の使用状況の第3例を示す図である。It is a figure which shows the 3rd example of a part of content memorize | stored in the management area | region 6 in FIG. 図1における管理領域6に記憶される「基準サイズ」が変更されて、メモリ5の使用状況が変化していく様子を表した図である。FIG. 7 is a diagram showing a state in which the usage status of the memory 5 is changed by changing the “reference size” stored in the management area 6 in FIG. 1. 最初適合法のアルゴリズムを適用した従来のメモリ管理システムにおけるメモリの使用状況の第1例を示す図である。It is a figure which shows the 1st example of the usage condition of the memory in the conventional memory management system to which the algorithm of the first adaptation method is applied. 最初適合法のアルゴリズムを適用した従来のメモリ管理システムにおけるメモリの使用状況の第2例を示す図である。It is a figure which shows the 2nd example of the usage condition of the memory in the conventional memory management system to which the algorithm of the first adaptation method is applied. 最初適合法のアルゴリズムを適用した従来のメモリ管理システムにおけるメモリの使用状況の第3例を示す図である。It is a figure which shows the 3rd example of the usage condition of the memory in the conventional memory management system to which the algorithm of a first adaptation method is applied.

符号の説明Explanation of symbols

1 CPU
2 OS
3 プログラム
4 メモリ管理手段
5、105 メモリ
6 管理領域
10 メモリ管理システム
1 CPU
2 OS
3 program 4 memory management means 5, 105 memory 6 management area 10 memory management system

Claims (2)

割り付けを要求されたデータに対して、当該メモリ領域の空き領域を選択して可変長の領域のメモリの割り付けを行うメモリ管理システムにおいて、
前記空き領域の探査方向を決するために用いる基準サイズを記憶する基準サイズ記憶手段を備え、
前記データのサイズが前記基準サイズより大きい場合と小さい場合とで、前記探査方向をメモリアドレスの昇順とするかと降順とするかとを互いに逆にしつつ、前記データのサイズ以上のサイズを有するものとして最初に探査された空き領域を選択して前記データに対するメモリの割り付けを行うことを特徴とするメモリ管理システム。
In a memory management system that allocates memory of a variable-length area by selecting a free area of the memory area for data requested to be allocated,
Reference size storage means for storing a reference size used for determining the search direction of the empty area,
It is first assumed that the size of the data is greater than or equal to the size of the data while reversing whether the search direction is ascending order or descending order of the memory address depending on whether the data size is larger or smaller than the reference size. A memory management system comprising: selecting a free area searched for and allocating a memory to the data.
前記データのサイズ以上のサイズを有する空き領域がない場合に、
前記基準サイズを前記データのサイズで書き換えて記憶することを特徴とする請求項1に記載のメモリ管理システム。
When there is no free space having a size larger than the size of the data,
The memory management system according to claim 1, wherein the reference size is rewritten and stored with the size of the data.
JP2003394923A 2003-11-26 2003-11-26 Memory management system Expired - Fee Related JP4033829B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2003394923A JP4033829B2 (en) 2003-11-26 2003-11-26 Memory management system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2003394923A JP4033829B2 (en) 2003-11-26 2003-11-26 Memory management system

Publications (2)

Publication Number Publication Date
JP2005157714A true JP2005157714A (en) 2005-06-16
JP4033829B2 JP4033829B2 (en) 2008-01-16

Family

ID=34720812

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2003394923A Expired - Fee Related JP4033829B2 (en) 2003-11-26 2003-11-26 Memory management system

Country Status (1)

Country Link
JP (1) JP4033829B2 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH1146490A (en) * 1997-07-28 1999-02-16 Matsushita Electric Works Ltd Motor rotational speed control circuit
KR100883651B1 (en) * 2006-05-18 2009-02-18 삼성전자주식회사 Method and apparatus for allocating free space of disc for a file to be written on the disc
JP2014238767A (en) * 2013-06-10 2014-12-18 カシオ計算機株式会社 Memory controller, memory control method, and program

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH1146490A (en) * 1997-07-28 1999-02-16 Matsushita Electric Works Ltd Motor rotational speed control circuit
KR100883651B1 (en) * 2006-05-18 2009-02-18 삼성전자주식회사 Method and apparatus for allocating free space of disc for a file to be written on the disc
JP2014238767A (en) * 2013-06-10 2014-12-18 カシオ計算機株式会社 Memory controller, memory control method, and program

Also Published As

Publication number Publication date
JP4033829B2 (en) 2008-01-16

Similar Documents

Publication Publication Date Title
US6505283B1 (en) Efficient memory allocator utilizing a dual free-list structure
JP5222381B2 (en) Configuration and method for managing available memory resources
US6922765B2 (en) Method of allocating physical memory space having pinned and non-pinned regions
JPH0546447A (en) Idle area retrieving method
US7454420B2 (en) Data sorting method and system
JPH05189281A (en) File assigning system for storage device
JP2858795B2 (en) Real memory allocation method
JP4758794B2 (en) Memory area allocation control device, memory area allocation control program, and memory area allocation control method
KR20070015521A (en) Memory allocation
JPH0883210A (en) Apparatus with electronic data processor
JPH0916463A (en) Dynamic allocation management system for memory area
JP2005537557A (en) Dynamic memory management
US7721065B2 (en) Reducing memory fragmentation by learning memory allocation patterns
CN114327917A (en) Memory management method, computing device and readable storage medium
CN107870922B (en) Method, equipment and system for data deduplication
JP4033829B2 (en) Memory management system
JP3610528B2 (en) Memory management method and apparatus
JP2006079463A (en) Method, apparatus, system, and program for managing buffer for recording time series data
JPWO2004084095A1 (en) Information search system, information search method, information search device, information search program, and computer-readable recording medium storing the program
US10452542B2 (en) Memory management process using data shift
JP3792194B2 (en) Memory management system
KR101980581B1 (en) Method for managing memory of tandem system
JP2002351739A (en) Memory managing method and data processor
JPH08249225A (en) Memory management device
JP2005050010A (en) Memory management method

Legal Events

Date Code Title Description
A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20070329

A131 Notification of reasons for refusal

Effective date: 20070403

Free format text: JAPANESE INTERMEDIATE CODE: A131

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20070523

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: 20071023

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20071023

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

Free format text: PAYMENT UNTIL: 20101102

Year of fee payment: 3

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

Free format text: JAPANESE INTERMEDIATE CODE: R150

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

Free format text: PAYMENT UNTIL: 20101102

Year of fee payment: 3

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

Year of fee payment: 4

Free format text: PAYMENT UNTIL: 20111102

LAPS Cancellation because of no payment of annual fees