JP2006039878A - Memory management method and memory management program in java (r) execution environment - Google Patents

Memory management method and memory management program in java (r) execution environment Download PDF

Info

Publication number
JP2006039878A
JP2006039878A JP2004217858A JP2004217858A JP2006039878A JP 2006039878 A JP2006039878 A JP 2006039878A JP 2004217858 A JP2004217858 A JP 2004217858A JP 2004217858 A JP2004217858 A JP 2004217858A JP 2006039878 A JP2006039878 A JP 2006039878A
Authority
JP
Japan
Prior art keywords
java
type
memory management
memory
compaction
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
JP2004217858A
Other languages
Japanese (ja)
Other versions
JP4504756B2 (en
Inventor
Tetsuyuki Kobayashi
哲之 小林
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.)
Aplix Corp
Original Assignee
Aplix 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 Aplix Corp filed Critical Aplix Corp
Priority to JP2004217858A priority Critical patent/JP4504756B2/en
Publication of JP2006039878A publication Critical patent/JP2006039878A/en
Application granted granted Critical
Publication of JP4504756B2 publication Critical patent/JP4504756B2/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

<P>PROBLEM TO BE SOLVED: To attain efficient data cooperation with a native program. <P>SOLUTION: When a request for the allocation of a Java(R) object to a heap region is issued, the Java(R) object is classified into a first type of Java(R) object and a second type of Java(R) object by a data type. When there is no vacancy in a first memory region to which the first type of Java(R) object is allocated, first compaction processing is executed to the first memory region, and when there is no vacancy in a second memory region to which the second type of Java(R) object is allocated, second compaction processing different from the first compaction processing is executed to the second memory region. Then, the first type of Java(R) object is allocated to the first memory region where vacancy is generated by the first compaction processing, and the second type of Java(R) object is allocated to the second memory region where vacancy is generated by the second compaction processing. <P>COPYRIGHT: (C)2006,JPO&NCIPI

Description

本発明は、Java(R)実行環境におけるメモリ管理方法及びメモリ管理プログラムに関するものである。   The present invention relates to a memory management method and a memory management program in a Java (R) execution environment.

Sun Microsystems社によって開発されたJava(R)技術は、特にインターネットの世界を中心に発展し、その後、サーバサイドJava(R)やアプリケーションソフトウェアの開発に利用され、最近では、携帯電話にも利用されている。携帯電話で利用されるJava(R)プログラムでは、音声、静止画、動画などのマルチメディアデータを取り扱うことが多い。特に昨今では、通信速度の高速化や表示画面の高精細化に伴ってこれらのマルチメディアデータのサイズは急激に増加する傾向にある。   Java (R) technology developed by Sun Microsystems developed especially in the Internet world, and was later used for development of server-side Java (R) and application software. Recently, it is also used for mobile phones. ing. Java (R) programs used in mobile phones often handle multimedia data such as audio, still images, and moving images. Especially in recent years, the size of these multimedia data tends to increase rapidly as the communication speed increases and the display screen becomes higher in definition.

このようなマルチメディアデータを再生したり加工する場合、Java(R)実行環境から独立した外部のネイティブプログラムによってこの処理が行われるのが一般的である。したがってこの場合、Java(R)実行環境とネイティブプログラムとの間のデータの連携動作が必要になる。ここでネイティブプログラムの例としては、音声や動画などの再生用プログラムとしてのデコーダ、記録用プログラムとしてのエンコーダさらには、通信用プロトコルスタックがある。   When such multimedia data is played back or processed, this processing is generally performed by an external native program independent of the Java® execution environment. Therefore, in this case, a data linkage operation between the Java® execution environment and the native program is required. Here, examples of the native program include a decoder as a reproduction program for audio and moving images, an encoder as a recording program, and a communication protocol stack.

Java(R)実行環境が備えるメモリ管理機構は、Java(R)オブジェクトを効率良く扱えるように設計されており、使用されなくなったメモリを回収するためのガーベジコレクションの機能や、メモリのフラグメンテーションを防ぐためにコンパクションの機構を備えている。   The memory management mechanism provided in the Java (R) execution environment is designed to handle Java (R) objects efficiently, preventing garbage collection functions to collect memory that is no longer used and memory fragmentation. It is equipped with a compaction mechanism.

しかし、このようなメモリ管理機構で管理されているJava(R)オブジェクトの中には、他のJava(R)オブジェクトと同様に管理することができないものが存在する場合がある。   However, there are cases in which Java (R) objects managed by such a memory management mechanism cannot be managed in the same manner as other Java (R) objects.

例えば、Java(R)実行環境とは非同期に動作するネイティブプログラムにより処理されるJava(R)オブジェクトがある場合、処理の途中でメモリ管理機構によるコンパクションが行なわれると、コンパクションにより処理中のデータが移動してネイティブプログラムから読み出せなくなってしまうという問題が生じる。   For example, if there is a Java (R) object that is processed by a native program that operates asynchronously with the Java (R) execution environment, if compaction is performed by the memory management mechanism in the middle of processing, the data being processed by the compaction is changed. The problem arises that the program cannot be read from the native program.

このような問題に対処するために、Java(R)プログラムが扱っているデータをネイティブプログラムにより処理する場合には、当該データを、Java(R)プログラム用に割り当てられたヒープ領域とは別に確保したメモリ領域にコピーしてから、ネイティブプログラムによる処理を行う方法がある。   In order to deal with such a problem, when data handled by the Java (R) program is processed by the native program, the data is secured separately from the heap area allocated for the Java (R) program. There is a method of performing processing by a native program after copying to the memory area.

上記の方法では、さらに、ネイティブプログラムがデータを更新した後に、当該ネイティブプログラムからJava(R)プログラムに処理を戻す場合には、データの整合性をとるために、ネイティブプログラムが更新したデータをヒープ領域にコピーして書き戻すことを行っている。   In the above method, when the native program updates the data and then returns the processing from the native program to the Java (R) program, the heap of the data updated by the native program is used to ensure data consistency. Copying back to the area and writing back.

このように、Java(R)プログラムが利用するヒープ領域と、ネイティブプログラムが利用する別のメモリ領域との間でデータをコピーする処理が発生すると、システムのメモリ容量が多量に消費されるとともに、コピーに要する時間だけ処理が遅延するという問題が発生する。特に、メモリサイズの大きい音声や動画のデータを扱う場合には、メモリ容量の消費はきわめて大きなものとなり、処理の遅延も顕著なものとなる。   As described above, when processing for copying data occurs between the heap area used by the Java (R) program and another memory area used by the native program, a large amount of memory capacity of the system is consumed. There is a problem that processing is delayed by the time required for copying. In particular, when handling audio or moving image data having a large memory size, the memory capacity is extremely large, and the processing delay becomes significant.

本発明は、このような課題に着目してなされたものであり、その目的とするところは、Java(R)実行環境で利用されるメモリ管理機構およびメモリ管理プログラムであって、特性の異なるデータであっても効率よく管理することができ、特にネイティブプログラムとの間で効率の良いデータの連携を行うことができるメモリ管理機構およびメモリ管理プログラムを提供することにある。   The present invention has been made paying attention to such a problem, and an object thereof is a memory management mechanism and a memory management program used in a Java (R) execution environment, which have different characteristics. However, it is an object of the present invention to provide a memory management mechanism and a memory management program that can be efficiently managed, and in particular, can perform efficient data linkage with a native program.

上記の目的を達成するために、本発明者は研究を重ねた結果、ネイティブプログラムから利用される頻度がJava(R)オブジェクトのデータ型によって相違すること、特にbyte[]のJava(R)オブジェクトがネイティブプログラムから利用される頻度が高いことを見出した。   In order to achieve the above object, the present inventor has conducted research, and the frequency used by the native program differs depending on the data type of the Java (R) object, in particular, the Java (R) object of byte []. Has been found to be frequently used from native programs.

本発明は、上記知見に鑑みてなされたものであって、第1の発明にかかるメモリ管理方法は、Java(R)実行環境におけるメモリ管理方法であって、Java(R)オブジェクトをヒープ領域にアロケートする要求が発生したときに、データ型によって、前記Java(R)オブジェクトを前記第1のタイプのJava(R)オブジェクトと、前記第2のタイプのJava(R)オブジェクトに分類するオブジェクト分類ステップと、前記第1のタイプのJava(R)オブジェクトがアロケートされる第1のメモリ領域に空きがない場合にはこの第1のメモリ領域に対して第1のコンパクション処理を実行し、前記第2のタイプのJava(R)オブジェクトがアロケートされる第2のメモリ領域に空きがない場合にはこの第2のメモリ領域に対して、前記第1のコンパクション処理とは異なる第2のコンパクション処理を実行するコンパクション実行ステップと、前記第1のコンパクション処理により空きが発生した前記第1のメモリ領域に前記第1のタイプのJava(R)オブジェクトをアロケートするとともに、前記第2のコンパクション処理により空きが発生した前記第2のメモリ領域に前記第2のタイプのJava(R)オブジェクトをアロケートするオブジェクトアロケーションステップと、を具備する。   The present invention has been made in view of the above knowledge, and the memory management method according to the first invention is a memory management method in a Java (R) execution environment, in which a Java (R) object is stored in a heap area. Object classification step of classifying the Java (R) object into the first type Java (R) object and the second type Java (R) object according to a data type when a request to allocate occurs If there is no free space in the first memory area to which the first type Java (R) object is allocated, the first compaction process is executed on the first memory area, and the second If there is no space in the second memory area to which the Java (R) object of this type is allocated, A compaction execution step for executing a second compaction process different from the first compaction process for the area; and the first type in the first memory area in which a space is generated by the first compaction process. And allocating the Java (R) object of the second type, and allocating the Java (R) object of the second type in the second memory area that has been vacated by the second compaction process. To do.

また、第2の発明は、第1の発明にかかるメモリ管理方法において、前記第2のメモリ領域には、所定のマークが付与されたJava(R)オブジェクトがアロケートされており、前記第2のコンパクション処理では、前記マークが付与されたJava(R)オブジェクトに対するコンパクション処理を行わない。   According to a second aspect of the present invention, in the memory management method according to the first aspect, a Java (R) object to which a predetermined mark is assigned is allocated in the second memory area. In the compaction process, the compaction process is not performed on the Java (R) object to which the mark is added.

また、第3の発明は、第2の発明にかかるメモリ管理方法において、ネイティブプログラムから利用されるJava(R)オブジェクトに所定のマークを付与する。   In addition, according to a third aspect, in the memory management method according to the second aspect, a predetermined mark is assigned to a Java (R) object used from a native program.

また、第4の発明は、第1から第3のいずれか1つの発明にかかるメモリ管理方法において、前記第2のタイプのJava(R)オブジェクトは、byteの1次元配列のデータ型をもつ。   According to a fourth invention, in the memory management method according to any one of the first to third inventions, the second type Java (R) object has a data type of a one-dimensional array of bytes.

また、第5の発明は、第1から第4のいずれか1つの発明にかかるメモリ管理方法において、前記byteの1次元配列をもつJava(R)オブジェクトは、音声データ、画像データあるいは通信データである。   The fifth invention is the memory management method according to any one of the first to fourth inventions, wherein the Java (R) object having the one-dimensional array of bytes is audio data, image data or communication data. is there.

また、第6の発明にかかるメモリ管理プログラムは、ネイティブプログラムとの間でデータの連携を行うJava(R)実行環境におけるメモリ管理プログラムであって、処理手段に、Java(R)オブジェクトをヒープ領域にアロケートする要求が発生したときに、前記ネイティブプログラムにより利用される頻度に応じて、前記Java(R)オブジェクトを第1のタイプのJava(R)オブジェクトと、第2のタイプのJava(R)オブジェクトに分類するオブジェクト分類処理と、前記第1のタイプのJava(R)オブジェクトがアロケートされる第1のメモリ領域に空きがない場合にはこの第1のメモリ領域に対して第1のコンパクション処理を実行し、前記第2のタイプのJava(R)オブジェクトがアロケートされる第2のメモリ領域に空きがない場合にはこの第2のメモリ領域に対して、前記第1のコンパクション処理とは異なる第2のコンパクション処理を実行するコンパクション処理と、前記第1のコンパクション処理により空きが発生した前記第1のメモリ領域に前記第1のタイプのJava(R)オブジェクトをアロケートするとともに、前記第2のコンパクション処理により空きが発生した前記第2のメモリ領域に前記第2のタイプのJava(R)オブジェクトをアロケートするオブジェクトアロケーション処理と、を実行させる。   A memory management program according to a sixth aspect of the present invention is a memory management program in a Java (R) execution environment for linking data with a native program, and a Java (R) object is stored in a heap area as a processing means. When a request for allocation occurs, the Java (R) object is changed into a first type Java (R) object and a second type Java (R) according to the frequency used by the native program. Object classification processing for classifying objects, and first compaction processing for the first memory area when there is no free space in the first memory area to which the first type Java (R) object is allocated And the second type Java (R) object is allocated When there is no free space in the second memory area, a compaction process for executing a second compaction process different from the first compaction process on the second memory area, and the first compaction process The first type Java (R) object is allocated to the first memory area where a space is generated, and the second type is stored in the second memory area where a space is generated by the second compaction process. And an object allocation process for allocating the Java (R) object.

また、第7の発明は、第6の発明にかかるメモリ管理プログラムにおいて、前記第2のメモリ領域には、所定のマークが付与されたJava(R)オブジェクトがアロケートされており、前記第2のコンパクション処理では、前記マークが付与されたJava(R)オブジェクトに対するコンパクション処理を行わない。   According to a seventh aspect of the present invention, in the memory management program according to the sixth aspect of the present invention, a Java (R) object to which a predetermined mark is assigned is allocated in the second memory area. In the compaction process, the compaction process is not performed on the Java (R) object to which the mark is added.

また、第8の発明は、第7の発明にかかるメモリ管理プログラムにおいて、ネイティブプログラムから利用されるJava(R)オブジェクトに所定のマークを付与する。   In addition, according to an eighth aspect, in the memory management program according to the seventh aspect, a predetermined mark is given to a Java (R) object used from a native program.

また、第9の発明は、第7または第8の発明にかかるメモリ管理プログラムにおいて、前記第2のタイプのJava(R)オブジェクトは、byteの1次元配列のデータ型をもつ。   According to a ninth invention, in the memory management program according to the seventh or eighth invention, the second type Java (R) object has a data type of a one-dimensional array of bytes.

また、第10の発明は、第6から第9のいずれか1つの発明にかかるメモリ管理プログラムにおいて、前記byteの1次元配列をもつJava(R)オブジェクトは、音声データ、画像データあるいは通信データである。   The tenth invention is the memory management program according to any one of the sixth to ninth inventions, wherein the Java (R) object having the one-dimensional array of bytes is audio data, image data or communication data. is there.

本発明によれば、Java(R)オブジェクトのデータ型に応じて、互いに異なるコンパクション処理が施されるメモリ領域を使い分けることができるので、オブジェクトのデータ型に応じて異なるコンパクション処理を適用することができ、これにより利用される形態や性質が異なるオブジェクトが存在しても、効率よくメモリ管理を行うことが可能である。   According to the present invention, it is possible to use different memory areas to be subjected to different compaction processes according to the data type of the Java (R) object, so that different compaction processes can be applied according to the data type of the object. Thus, even if there are objects with different forms and properties, it is possible to perform memory management efficiently.

本発明は、特にネイティブプログラムによって利用される頻度が高いデータ型のJava(R)オブジェクトとそれ以外のオブジェクトとで、互いに異なるコンパクション処理が施されるメモリ領域を使い分ける場合に適用することが好適である。この場合には、ネイティブプログラムによって利用されるJava(R)オブジェクトについてはコンパクション処理を行わないようにすることで、コンパクション処理時のオブジェクト移動に対処するためのメモリ領域の確保やコピー動作が不要になり、Java(R)プログラムとネイティブプログラムとのデータ連携を極めて効率良く行うことが可能になる。   The present invention is particularly suitable for a case where a memory area that is subjected to different compaction processing is selectively used for a Java (R) object of a data type frequently used by a native program and other objects. is there. In this case, by avoiding compaction processing for Java (R) objects used by the native program, it is not necessary to secure a memory area and copy operation to deal with object movement during compaction processing. Thus, it is possible to perform data linkage between the Java (R) program and the native program extremely efficiently.

まず、本実施形態の概略を説明する。Java(R)実行環境において、多くのJava(R)オブジェクトはJava(R)プログラムのみから利用されるものであり、ネイティブプログラムとの間でデータの連携を行う場合に、当該ネイティブプログラムにより利用されるJava(R)オブジェクトはごく一部である。ここで、ネイティブプログラムで利用されるJava(R)オブジェクトについてはコンパクション処理によるアドレスの移動に対処する必要があるものの、その他のJava(R)オブジェクトについてはそのような対処を必要としない。したがって、それらを区別して管理することで効率の良いメモリ運用を実現することが可能である。   First, an outline of the present embodiment will be described. In the Java (R) execution environment, many Java (R) objects are used only by the Java (R) program, and are used by the native program when data is linked with the native program. Java (R) objects are a small part. Here, the Java (R) object used in the native program needs to cope with the movement of the address by the compaction process, but the other Java (R) object does not need such a countermeasure. Therefore, efficient memory operation can be realized by distinguishing and managing them.

本発明者がJava(R)と連携するネイティブプログラムを注意深く観察した結果、ネイティブプログラムによって利用されるJava(R)オブジェクトは、殆どの場合にデータ型としてbyteの1次元配列をもつことがわかった。byteの1次元配列をもつJava(R)オブジェクト(byte[]オブジェクト)の具体例としては、音声データや画像(動画を含む)データといったマルチメディアデータ、通信データなどが挙げられる。   As a result of careful observation of the native program linked with Java (R) by the present inventor, it has been found that the Java (R) object used by the native program has a one-dimensional array of bytes as a data type in most cases. . Specific examples of Java (R) objects (byte [] objects) having a one-dimensional array of bytes include multimedia data such as audio data and image (including moving image) data, communication data, and the like.

そこで本実施形態では、通常のJava(R)オブジェクトは第1のタイプのJava(R)オブジェクト、byte[]オブジェクトは第2のタイプのJava(R)オブジェクトとして分類し、第1のタイプのJava(R)オブジェクトはヒープ領域内の第1の領域に格納し、第2のタイプのJava(R)オブジェクトはヒープ領域内の第2の領域に格納するようにする。そして、第2の領域内のbyte[]オブジェクトのうち、ネイティブプログラムにより利用されるJava(R)オブジェクトについては、ネイティブプログラムとのデータ連携の間コンパクション処理時の移動を禁止する所定のマークを付与する。ここでは移動させないJava(R)オブジェクトについてはマークビットをON状態にセットすることによりロックする。ロックされたJava(R)オブジェクトは後述のようにコンパクション処理の対象外となり移動されることはない。ネイティブプログラムとのデータ連携が終了した後は、マークビットがOFF状態とされて、ロックが解除される。   Therefore, in the present embodiment, a normal Java (R) object is classified as a first type Java (R) object, a byte [] object is classified as a second type Java (R) object, and the first type Java (R) object is classified. The (R) object is stored in the first area in the heap area, and the second type Java (R) object is stored in the second area in the heap area. Among the byte [] objects in the second area, a Java (R) object used by the native program is given a predetermined mark that prohibits movement during compaction processing during data linkage with the native program. To do. Here, Java (R) objects that are not moved are locked by setting the mark bit to the ON state. The locked Java® object is not subject to compaction processing and will not be moved, as will be described later. After the data linkage with the native program is completed, the mark bit is turned off and the lock is released.

なお、コンパクション処理時の移動を許可するか禁止するかを区別する方法として、所定のマークをJava(R)オブジェクトにそれぞれ付与するのでなく、Java(R)オブジェクトごとに移動の許可あるいは禁止の情報を書き込んだ管理テーブルを用いるようにしても良い。   As a method for distinguishing whether to permit or prohibit movement during compaction processing, instead of assigning a predetermined mark to each Java (R) object, information on permission or prohibition of movement for each Java (R) object. A management table in which is written may be used.

新たなJava(R)オブジェクトをヒープ領域にアロケートする要求が発生したときに、アロケートするために十分なメモリ領域が存在しない場合には、使用されなくなったメモリを回収するためのガーベジコレクション処理や、細かく分断された使用中メモリ領域をまとめて連続したメモリ領域にするコンパクション処理を行うことになるが、この場合、第1のタイプのJava(R)オブジェクトが格納されている第1の領域ではコンパクション処理によってすべてのオブジェクトが移動され、フラグメンテーションの発生が防止される。一方、第2のタイプのJava(R)オブジェクトが格納された第2の領域に対するコンパクション処理ではこれとは異なるコンパクション処理が実行される。すなわち、ここでのコンパクション処理は、マークビットがON状態にセットされてロックされているオブジェクトについては移動させず、それ以外のオブジェクトのみを移動させることで行われる。   When a request for allocating a new Java (R) object to the heap area occurs, if there is not enough memory area to allocate, garbage collection processing for collecting memory that is no longer used, A compaction process is performed in which the memory areas in use that are finely divided are combined into a continuous memory area. In this case, compaction is performed in the first area in which the first type Java (R) object is stored. The process moves all objects and prevents fragmentation. On the other hand, in the compaction process for the second area in which the second type Java (R) object is stored, a compaction process different from this is executed. That is, the compaction processing here is performed by moving only the other objects without moving the objects that are locked with the mark bit set to the ON state.

そして、上記コンパクション処理により空きが発生した第1のメモリ領域に第1のタイプのJava(R)オブジェクトがアロケートされ、上記コンパクション処理により空きが発生した第2のメモリ領域に第2のタイプのJava(R)オブジェクトがアロケートされる。   Then, a first type Java (R) object is allocated to the first memory area where a space is generated by the compaction process, and a second type Java is stored in the second memory area where a space is generated by the compaction process. (R) The object is allocated.

このように本実施形態においては、ネイティブプログラムにより利用される頻度の高いbyte[]オブジェクトは第2のメモリ領域に配置され、さらにネイティブプログラムにより実際に利用されている間は当該オブジェクトのマークビットがON状態にセットされる。そして、第2のメモリ領域に対するコンパクション処理は、マークビットがON状態のオブジェクトを移動させないので、ネイティブプログラムにより利用されているオブジェクトがコンパクション処理により移動されることはない。したがって、コンパクション処理によるオブジェクト移動に対応するために新たなメモリ領域をヒープ領域外に確保してコピーする動作が不要になり、これによってネイティブプログラムとのデータ連携を効率良く行うことが可能になる。この場合、byte[]オブジェクト以外のオブジェクトについては通常のコンパクション処理が行われるので、従来のJava(R)実行環境におけるメモリ管理と同様のメモリ管理が可能である。   As described above, in this embodiment, the byte [] object that is frequently used by the native program is arranged in the second memory area, and the mark bit of the object is set while the object is actually used by the native program. Set to ON state. The compaction process for the second memory area does not move the object whose mark bit is in the ON state. Therefore, the object used by the native program is not moved by the compaction process. Therefore, an operation for securing and copying a new memory area outside the heap area in order to cope with object movement by compaction processing becomes unnecessary, thereby enabling efficient data linkage with the native program. In this case, normal compaction processing is performed for objects other than the byte [] object, and therefore memory management similar to memory management in the conventional Java® execution environment is possible.

第2のメモリ領域に適用されるメモリ管理(特にコンパクション処理)はJava(R)オブジェクトがロックされているか否かの判断を伴うためオーバーヘッドを伴うが、第1のメモリ領域には従来通りのメモリ管理が適用されるため、その影響は小さく抑えることができる。   The memory management (particularly compaction processing) applied to the second memory area involves an overhead because it involves determining whether or not the Java® object is locked, but the first memory area has a conventional memory. Since management is applied, the impact can be minimized.

また、ネイティブプログラムから利用されるJava(R)オブジェクトは、特にマルチメディアデータであると容量が大きい場合が多く、このようなJava(R)オブジェクトがJava(R)実行環境の利用するヒープ領域全体に分散してロックされるとフラグメンテーションの発生が問題となる。しかし、本実施形態では、ネイティブから利用されるJava(R)オブジェクトは主として第2のメモリ領域に配置されるので、フラグメンテーションが発生したとしてもその影響は第2のメモリ領域に限定されたものとすることができる。   In addition, Java (R) objects used from native programs often have a large capacity especially in the case of multimedia data, and such Java (R) objects use the entire heap area used by the Java (R) execution environment. Generation of fragmentation becomes a problem when distributed and locked. However, in this embodiment, the Java (R) object used from the native is mainly arranged in the second memory area, so even if fragmentation occurs, the influence is limited to the second memory area. can do.

なお、byte[]オブジェクト以外のオブジェクトをネイティブプログラムから利用する場合には、そのようなオブジェクトは第1のメモリ領域に配置されているため、従来と同様にヒープ領域外部にコピーする必要があるが、その頻度は極めて低いので問題はない。   Note that when an object other than the byte [] object is used from a native program, such an object must be copied to the outside of the heap area as in the conventional case because it is located in the first memory area. Because the frequency is very low, there is no problem.

また、通常のJava(R)オブジェクトと、ネイティブプログラムと連携するJava(R)オブジェクトとでは、サイズや生存期間の傾向が異なるので、ネイティブプログラムと連携する頻度が高いデータと低いデータとを分離して管理することでメモリ管理の効率も向上する。   In addition, the normal Java (R) object and the Java (R) object linked with the native program have different sizes and lifespan trends. Therefore, the data that is frequently linked with the native program is separated from the low data. Management improves the efficiency of memory management.

さらに、Java(R)言語仕様に対して新たな拡張を加えたわけではないので、Java(R)実行環境側だけの修正で済み、既存のプログラムを修正する必要がない等、既存のプログラムとの親和性を維持することができる。   Furthermore, since no new extensions have been added to the Java (R) language specification, it is only necessary to modify the Java (R) execution environment, and there is no need to modify existing programs. Affinity can be maintained.

以下、図面を参照して本発明の実施形態を詳細に説明する。   Hereinafter, embodiments of the present invention will be described in detail with reference to the drawings.

図1は、本発明を実施するためのハードウェア構成の説明図であり、ここでは、本実施形態のJava(R)実行環境を搭載した組み込み機器(例えば携帯電話)のハードウェア構成を示している。図1において、メモリ11は種々のプログラムやデータを格納する部分である。入出力部13はユーザインタフェースとなる部分であり、入力キー、マイク、スピーカなどで構成される。表示部12は種々のメニューや動作状況等の情報を表示する部分である。CPU10は、装置各部の動作を制御する部分である。本実施形態で用いられるJava(R)オブジェクト分類機能、メモリ領域コンパクション機能、Java(R)オブジェクトアロケーション機能は、CPU10がメモリ11に格納された各種のプログラムを読み出して実行したときに仮想的に構築されるようになっている。   FIG. 1 is an explanatory diagram of a hardware configuration for carrying out the present invention. Here, a hardware configuration of an embedded device (for example, a mobile phone) equipped with the Java (R) execution environment of the present embodiment is shown. Yes. In FIG. 1, a memory 11 is a part for storing various programs and data. The input / output unit 13 serves as a user interface and includes input keys, a microphone, a speaker, and the like. The display unit 12 is a part for displaying information such as various menus and operation statuses. The CPU 10 is a part that controls the operation of each part of the apparatus. The Java (R) object classification function, the memory area compaction function, and the Java (R) object allocation function used in this embodiment are virtually constructed when the CPU 10 reads and executes various programs stored in the memory 11. It has come to be.

図2は、本発明を実施するためのソフトウェア構成の説明図である。図2に示すように、プラットフォーム(OS及びハードウェア)23上には、Java(R)実行環境としてVM(Virtual Machine)24、クラスライブラリ22、Java(R)アプリケーション20が搭載されている。VM24は、Java(R)バイトコードが格納されたクラスファイルをネイティブコードに変換しながら実行するプログラムである。   FIG. 2 is an explanatory diagram of a software configuration for carrying out the present invention. As shown in FIG. 2, on a platform (OS and hardware) 23, a VM (Virtual Machine) 24, a class library 22, and a Java (R) application 20 are mounted as a Java (R) execution environment. The VM 24 is a program that is executed while converting a class file storing Java (R) bytecode into native code.

なお、VM24は、Java(R)ヒープ領域25を有し、ここでは図3に示すように、通常のJava(R)オブジェクトがアロケートされる第1の領域25−1と、byte[]オブジェクトがアロケートされる第2の領域25−2とが設けられている。さらに、Java(R)実行環境とデータの連携(リード・ライト)を行うネイティブプログラムアプリケーション1(26)、2(27)が搭載されている。   The VM 24 has a Java (R) heap area 25. Here, as shown in FIG. 3, the first area 25-1 to which a normal Java (R) object is allocated, and a byte [] object are stored. A second region 25-2 to be allocated is provided. Furthermore, native program applications 1 (26) and 2 (27) for performing data linkage (read / write) with the Java (R) execution environment are installed.

図4は、Java(R)オブジェクトを本実施形態の方法によりアロケートする手順を示すフローチャートである。   FIG. 4 is a flowchart showing a procedure for allocating a Java (R) object by the method of this embodiment.

Java(R)オブジェクトをヒープ領域にアロケートする要求が発生したとき、CPU10は、当該Java(R)オブジェクトのデータ型がbyte[]であるか否かを判断し(ステップS1)、NOの場合、すなわち通常のJava(R)オブジェクトである場合にはJava(R)ヒープ領域25の第1の領域25−1に空きがあるか否かを判断する(ステップS2)。ここでの判断がYESの場合には第1の領域25−1に当該Java(R)オブジェクトをアロケートし(ステップS5)、その後、終了する。   When a request for allocating a Java (R) object to the heap area occurs, the CPU 10 determines whether or not the data type of the Java (R) object is byte [] (step S1). That is, if it is a normal Java (R) object, it is determined whether or not there is a free space in the first area 25-1 of the Java (R) heap area 25 (step S2). If the determination here is YES, the Java (R) object is allocated to the first area 25-1 (step S5), and then the process ends.

また、ステップS2の判断がNOの場合には、第1、第2の領域25−1,25−2に対してガーベジコレクションを実行して使用されていない領域を開放するとともに、第1の領域25−1内の使用中のJava(R)オブジェクトを移動させるコンパクション処理を実行する(ステップS3)。次に、上記のガーベジコレクションとコンパクション処理により第1の領域25−1に空きが生成されたか否かを判断し(ステップS4)、YESの場合には第1の領域25−1にJava(R)オブジェクトをアロケートし(ステップS5)、その後、終了する。一方、ステップS4の判断がNOの場合には空き領域なしのエラーメッセージを表示して(ステップS6)、終了する。   If the determination in step S2 is NO, garbage collection is performed on the first and second areas 25-1 and 25-2 to release unused areas, and the first area A compaction process for moving the Java (R) object in use in 25-1 is executed (step S3). Next, it is determined whether or not an empty space has been generated in the first area 25-1 by the above-described garbage collection and compaction process (step S4). If YES, Java (R ) Allocate the object (step S5), and then end. On the other hand, if the determination in step S4 is NO, an error message indicating no free space is displayed (step S6), and the process ends.

一方、ステップS1の判断がYESの場合には、Java(R)ヒープ領域25の第2の領域25−2に空きがあるか否かを判断する(ステップS7)。ここでの判断がYESの場合には第2の領域25−2に当該Java(R)オブジェクトをアロケートし(ステップS10)、その後、終了する。   On the other hand, if the determination in step S1 is yes, it is determined whether or not there is a free space in the second area 25-2 of the Java (R) heap area 25 (step S7). If the determination here is YES, the Java (R) object is allocated to the second area 25-2 (step S10), and then the process ends.

また、ステップS7の判断がNOの場合には、第1、第2の領域25−1,25−2に対してガーベジコレクションを実行して使用されていない領域を開放するとともに、第2の領域25−2内の、ロックされていない使用中のJava(R)オブジェクトのみを移動させるコンパクション処理を実行する(ステップS8)。次に、上記のガーベジコレクションとコンパクション処理により第2の領域25−2に空きが生成されたか否かを判断し(ステップS9)、YESの場合には第2の領域25−2にJava(R)オブジェクトをアロケートし(ステップS10)、その後、終了する。一方、ステップS9の判断がNOの場合には空き領域なしのエラーメッセージを表示して(ステップS6)、終了する。   When the determination in step S7 is NO, garbage collection is performed on the first and second areas 25-1 and 25-2 to release unused areas, and the second area A compaction process for moving only the unlocked Java (R) object in 25-2 is executed (step S8). Next, it is determined whether or not an empty space is generated in the second area 25-2 by the above-described garbage collection and compaction processing (step S9). If YES, Java (R ) Allocate the object (step S10), and then end. On the other hand, if the determination in step S9 is NO, an error message indicating no free space is displayed (step S6), and the process ends.

なお、本発明は、上記実施の形態に限らず種々変形が可能である。例えば、Java(R)の後継となる言語系が新たに提案された場合であっても、当該言語系が実行環境によるガーベジコレクションやコンパクションといったメモリ管理を想定したものであれば、本発明のメモリ管理方法およびメモリ管理プログラムを上記実施の形態と同様に適用することが可能である。また、ガーベジコレクションやコンパクションの方法にも制限はなく、適用可能な方法を適宜使用することができる。また、そのガーベジコレクションやコンパクションを行うタイミングも上記実施の形態に限られるものではなく、Java(R)オブジェクトをアロケートする要求発生のタイミングとは非同期にこれらを行うようにしてもよい。   The present invention is not limited to the above embodiment, and various modifications can be made. For example, even when a language system succeeding Java (R) is newly proposed, if the language system assumes memory management such as garbage collection and compaction by the execution environment, the memory of the present invention The management method and the memory management program can be applied in the same manner as in the above embodiment. Moreover, there is no restriction | limiting in the method of garbage collection or compaction, The applicable method can be used suitably. Also, the timing of performing garbage collection and compaction is not limited to the above embodiment, and these may be performed asynchronously with the timing of generation of a request for allocating a Java (R) object.

本発明を実施するためのハードウェア構成の説明図である。It is explanatory drawing of the hardware constitutions for implementing this invention. 本発明を実施するためのソフトウェア構成の説明図である。It is explanatory drawing of the software structure for implementing this invention. Java(R)オブジェクトをアロケートするための2つの領域を示す図である。It is a figure which shows two area | regions for allocating a Java (R) object. Java(R)オブジェクトを本実施形態の方法によりアロケートする手順を示すフローチャートである。It is a flowchart which shows the procedure which allocates a Java (R) object by the method of this embodiment.

符号の説明Explanation of symbols

10…CPU、11…メモリ、12…表示部、13…入出力部、20…Java(R)アプリケーション、21…AMS、22…クラスライブラリ、23…プラットフォーム、24…VM、25…Java(R)ヒープ領域、25−1…第1の領域、25−2…第2の領域、26…ネイティブアプリケーション1、27…ネイティブアプリケーション2。 DESCRIPTION OF SYMBOLS 10 ... CPU, 11 ... Memory, 12 ... Display part, 13 ... Input / output part, 20 ... Java (R) application, 21 ... AMS, 22 ... Class library, 23 ... Platform, 24 ... VM, 25 ... Java (R) Heap area, 25-1 ... first area, 25-2 ... second area, 26 ... native application 1, 27 ... native application 2.

Claims (10)

Java(R)実行環境におけるメモリ管理方法であって、
Java(R)オブジェクトをヒープ領域にアロケートする要求が発生したときに、データ型によって、前記Java(R)オブジェクトを第1のタイプのJava(R)オブジェクトと、第2のタイプのJava(R)オブジェクトに分類するオブジェクト分類ステップと、
前記第1のタイプのJava(R)オブジェクトがアロケートされる第1のメモリ領域に空きがない場合にはこの第1のメモリ領域に対して第1のコンパクション処理を実行し、前記第2のタイプのJava(R)オブジェクトがアロケートされる第2のメモリ領域に空きがない場合にはこの第2のメモリ領域に対して、前記第1のコンパクション処理とは異なる第2のコンパクション処理を実行するコンパクション実行ステップと、
前記第1のコンパクション処理により空きが発生した前記第1のメモリ領域に前記第1のタイプのJava(R)オブジェクトをアロケートするとともに、前記第2のコンパクション処理により空きが発生した前記第2のメモリ領域に前記第2のタイプのJava(R)オブジェクトをアロケートするオブジェクトアロケーションステップと、
を具備することを特徴とするメモリ管理方法。
A memory management method in a Java (R) execution environment,
When a request for allocating a Java (R) object to the heap area occurs, the Java (R) object is classified into a first type Java (R) object and a second type Java (R) depending on the data type. An object classification step for classifying objects;
When there is no free space in the first memory area to which the first type Java (R) object is allocated, the first compaction process is executed on the first memory area, and the second type Compaction that executes a second compaction process different from the first compaction process on the second memory area when there is no free space in the second memory area to which the Java (R) object is allocated Execution steps;
The second memory in which the first type Java (R) object is allocated to the first memory area in which free space has been generated by the first compaction processing, and free space has been generated by the second compaction processing. An object allocation step for allocating the second type Java object in a region;
A memory management method comprising:
前記第2のメモリ領域には、所定のマークが付与されたJava(R)オブジェクトがアロケートされており、前記第2のコンパクション処理では、前記マークが付与されたJava(R)オブジェクトに対するコンパクション処理を行わないことを特徴とする請求項1に記載のメモリ管理方法。 In the second memory area, a Java (R) object to which a predetermined mark is assigned is allocated, and in the second compaction process, a compaction process for the Java (R) object to which the mark is assigned is performed. The memory management method according to claim 1, wherein the memory management method is not performed. ネイティブプログラムから利用されるJava(R)オブジェクトに所定のマークを付与することを特徴とする請求項2に記載のメモリ管理方法。 3. The memory management method according to claim 2, wherein a predetermined mark is assigned to a Java (R) object used from a native program. 前記第2のタイプのJava(R)オブジェクトは、byteの1次元配列のデータ型をもつことを特徴とする請求項1から3のいずれか1項に記載のメモリ管理方法。 4. The memory management method according to claim 1, wherein the second type Java (R) object has a data type of a one-dimensional array of bytes. 5. 前記byteの1次元配列をもつJava(R)オブジェクトは、音声データ、画像データあるいは通信データであることを特徴とする請求項1から4のいずれか1項に記載のメモリ管理方法。 5. The memory management method according to claim 1, wherein the Java (R) object having the one-dimensional array of bytes is audio data, image data, or communication data. ネイティブプログラムとの間でデータの連携を行うJava(R)実行環境におけるメモリ管理プログラムであって、
処理手段に、
Java(R)オブジェクトをヒープ領域にアロケートする要求が発生したときに、データ型によって、前記Java(R)オブジェクトを第1のタイプのJava(R)オブジェクトと、第2のタイプのJava(R)オブジェクトに分類するオブジェクト分類処理と、
前記第1のタイプのJava(R)オブジェクトがアロケートされる第1のメモリ領域に空きがない場合にはこの第1のメモリ領域に対して第1のコンパクション処理を実行し、前記第2のタイプのJava(R)オブジェクトがアロケートされる第2のメモリ領域に空きがない場合にはこの第2のメモリ領域に対して、前記第1のコンパクション処理とは異なる第2のコンパクション処理を実行するコンパクション処理と、
前記第1のコンパクション処理により空きが発生した前記第1のメモリ領域に前記第1のタイプのJava(R)オブジェクトをアロケートするとともに、前記第2のコンパクション処理により空きが発生した前記第2のメモリ領域に前記第2のタイプのJava(R)オブジェクトをアロケートするオブジェクトアロケーション処理と、
を実行させることを特徴とするメモリ管理プログラム。
A memory management program in a Java (R) execution environment that performs data linkage with a native program,
In processing means,
When a request for allocating a Java (R) object to the heap area occurs, the Java (R) object is classified into a first type Java (R) object and a second type Java (R) depending on the data type. Object classification processing to classify objects,
When there is no free space in the first memory area to which the first type Java (R) object is allocated, the first compaction process is executed on the first memory area, and the second type Compaction that executes a second compaction process different from the first compaction process on the second memory area when there is no free space in the second memory area to which the Java (R) object is allocated Processing,
The second memory in which the first type Java (R) object is allocated to the first memory area in which free space has been generated by the first compaction processing, and free space has been generated by the second compaction processing. An object allocation process for allocating the second type Java (R) object in a region;
A memory management program.
前記第2のメモリ領域には、所定のマークが付与されたJava(R)オブジェクトがアロケートされており、前記第2のコンパクション処理では、前記マークが付与されたJava(R)オブジェクトに対するコンパクション処理を行わないことを特徴とする請求項6に記載のメモリ管理プログラム。 In the second memory area, a Java (R) object to which a predetermined mark is assigned is allocated, and in the second compaction process, a compaction process for the Java (R) object to which the mark is assigned is performed. The memory management program according to claim 6, wherein the memory management program is not performed. ネイティブプログラムから利用されるJava(R)オブジェクトに所定のマークを付与することを特徴とする請求項7に記載のメモリ管理プログラム。 8. The memory management program according to claim 7, wherein a predetermined mark is assigned to a Java (R) object used from a native program. 前記第2のタイプのJava(R)オブジェクトは、byteの1次元配列のデータ型をもつことを特徴とする請求項6から8のいずれか1項に記載のメモリ管理プログラム。 9. The memory management program according to claim 6, wherein the second type Java (R) object has a data type of a one-dimensional array of bytes. 前記byteの1次元配列をもつJava(R)オブジェクトは、音声データ、画像データあるいは通信データであることを特徴とする請求項6から9のいずれか1項に記載のメモリ管理プログラム。 The memory management program according to any one of claims 6 to 9, wherein the Java (R) object having a one-dimensional array of bytes is audio data, image data, or communication data.
JP2004217858A 2004-07-26 2004-07-26 Memory management method and memory management program in Java (registered trademark) execution environment Expired - Fee Related JP4504756B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2004217858A JP4504756B2 (en) 2004-07-26 2004-07-26 Memory management method and memory management program in Java (registered trademark) execution environment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2004217858A JP4504756B2 (en) 2004-07-26 2004-07-26 Memory management method and memory management program in Java (registered trademark) execution environment

Publications (2)

Publication Number Publication Date
JP2006039878A true JP2006039878A (en) 2006-02-09
JP4504756B2 JP4504756B2 (en) 2010-07-14

Family

ID=35904823

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2004217858A Expired - Fee Related JP4504756B2 (en) 2004-07-26 2004-07-26 Memory management method and memory management program in Java (registered trademark) execution environment

Country Status (1)

Country Link
JP (1) JP4504756B2 (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007004506A (en) * 2005-06-24 2007-01-11 Mitsubishi Electric Corp Storage management device
WO2008096602A1 (en) * 2007-02-05 2008-08-14 Kyoto University Memory management method, memory management device, and recording medium containing the memory management program
JP2011100230A (en) * 2009-11-04 2011-05-19 Fujitsu Ltd Program and device having memory management function
JP2012221034A (en) * 2011-04-05 2012-11-12 Nippon Telegr & Teleph Corp <Ntt> Memory management device, memory management method, and memory management program

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS61262949A (en) * 1985-05-17 1986-11-20 Fujitsu Ltd Control system for memory capacity
JPH0218637A (en) * 1988-07-06 1990-01-22 Nec Software Ltd Memory control method
JPH0695954A (en) * 1992-06-15 1994-04-08 Microsoft Corp Computer system for conservative stack and generational heap-garbage collection and method thereof
JP2002278828A (en) * 2001-03-21 2002-09-27 Sony Corp Garbage collection performing method, computer program, program storage medium and information processor

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS61262949A (en) * 1985-05-17 1986-11-20 Fujitsu Ltd Control system for memory capacity
JPH0218637A (en) * 1988-07-06 1990-01-22 Nec Software Ltd Memory control method
JPH0695954A (en) * 1992-06-15 1994-04-08 Microsoft Corp Computer system for conservative stack and generational heap-garbage collection and method thereof
JP2002278828A (en) * 2001-03-21 2002-09-27 Sony Corp Garbage collection performing method, computer program, program storage medium and information processor

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007004506A (en) * 2005-06-24 2007-01-11 Mitsubishi Electric Corp Storage management device
WO2008096602A1 (en) * 2007-02-05 2008-08-14 Kyoto University Memory management method, memory management device, and recording medium containing the memory management program
JP2011100230A (en) * 2009-11-04 2011-05-19 Fujitsu Ltd Program and device having memory management function
JP2012221034A (en) * 2011-04-05 2012-11-12 Nippon Telegr & Teleph Corp <Ntt> Memory management device, memory management method, and memory management program

Also Published As

Publication number Publication date
JP4504756B2 (en) 2010-07-14

Similar Documents

Publication Publication Date Title
JP5292473B2 (en) File I / O scheduling using instant chunking of data
US7203941B2 (en) Associating a native resource with an application
US6757890B1 (en) Methods and apparatus for enabling local Java object allocation and collection
US7707337B2 (en) Object-based storage device with low process load and control method thereof
JP5236367B2 (en) Shared Java JAR file
US20040095387A1 (en) Virtualized and realized user interface controls
US20020087589A1 (en) Methods and apparatus for optimizing garbage collection
JP2014059906A (en) Method and apparatus for implementing individual class loader
JP2009532761A (en) Query and describe discrete areas of flash storage
JPH113269A (en) System and method for assisting accurate garbage collection by separating contents of stack into sub-stacks
JP4295805B2 (en) MEMORY MANAGEMENT DEVICE, MEMORY MANAGEMENT METHOD, MEMORY MANAGEMENT PROGRAM, AND COMPUTER-READABLE RECORDING MEDIUM CONTAINING THE PROGRAM
JP2006294028A (en) System for providing direct execution function, computer system, method and program
JP4504756B2 (en) Memory management method and memory management program in Java (registered trademark) execution environment
US20100077163A1 (en) Memory Management Method, Memory Management Apparatus, and Recording Medium Recording the Memory Management Program
CN113490916A (en) Stack management
JP7025104B2 (en) Information processing equipment, methods and programs
JP6245028B2 (en) Execution control method, execution control program, and execution control apparatus
CN109923527B (en) Variable type builder
JP4589095B2 (en) Program execution device, program execution method, and data area management program
JPH11232103A (en) Program link system and method search system
JP7080698B2 (en) Information processing equipment
JP2007299036A (en) Information processor and information processing method
JP2005084900A (en) Program management system
AU2014268230A1 (en) Cyclic allocation buffers
CN115827550A (en) Data processing method and related device

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20061020

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20100202

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20100209

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20100323

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

A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20100423

R150 Certificate of patent or registration of utility model

Free format text: JAPANESE INTERMEDIATE CODE: R150

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

Free format text: PAYMENT UNTIL: 20130430

Year of fee payment: 3

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

Free format text: PAYMENT UNTIL: 20140430

Year of fee payment: 4

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

LAPS Cancellation because of no payment of annual fees