JP5357989B2 - Memory management device, memory management method, and memory management program - Google Patents

Memory management device, memory management method, and memory management program Download PDF

Info

Publication number
JP5357989B2
JP5357989B2 JP2012040126A JP2012040126A JP5357989B2 JP 5357989 B2 JP5357989 B2 JP 5357989B2 JP 2012040126 A JP2012040126 A JP 2012040126A JP 2012040126 A JP2012040126 A JP 2012040126A JP 5357989 B2 JP5357989 B2 JP 5357989B2
Authority
JP
Japan
Prior art keywords
memory
group
bundle
integrated value
amount
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.)
Expired - Fee Related
Application number
JP2012040126A
Other languages
Japanese (ja)
Other versions
JP2013175107A (en
Inventor
裕士 黒田
育生 山崎
育生 依田
重邦 近藤
浩二 矢田
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.)
Nippon Telegraph and Telephone Corp
Original Assignee
Nippon Telegraph and Telephone 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 Nippon Telegraph and Telephone Corp filed Critical Nippon Telegraph and Telephone Corp
Priority to JP2012040126A priority Critical patent/JP5357989B2/en
Publication of JP2013175107A publication Critical patent/JP2013175107A/en
Application granted granted Critical
Publication of JP5357989B2 publication Critical patent/JP5357989B2/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Description

本発明は、OSGi標準仕様に基づくバンドルが利用するメモリを管理する技術に関する。   The present invention relates to a technique for managing a memory used by a bundle based on an OSGi standard specification.

〔OSGiについて〕
OSGi(Open Services Gateway interactive)は、ソフトウェアのモジュール化技術である。OSGi標準仕様に基づくソフトウェアモジュールは、バンドルと呼ばれている。
[About OSGi]
OSGi (Open Services Gateway interactive) is a software modularization technology. A software module based on the OSGi standard specification is called a bundle.

システムアーキテクチャとしては、図16に示すように、動作端末のOS(Operating System)上でJavaVM(Java(登録商標) Virtual Machine:Java仮想マシン)が1つのプロセスとして動作し、JavaVM上でバンドルの実行環境であるOSGiFW(OSGi Framework)が動作する。このOSGiFW上で複数のバンドルを動作させることができる。OSGiFWおよびバンドルは、Javaプログラムである。   As shown in FIG. 16, JavaVM (Java (registered trademark) Virtual Machine) operates as one process on the operating terminal OS (Operating System), and the bundle is executed on the JavaVM. OSGiFW (OSGi Framework), which is an environment, operates. A plurality of bundles can be operated on the OSGiFW. OSGiFW and bundles are Java programs.

JavaプログラムをJavaVM上で動作させるには、まず、Java言語で書かれたソースコードを、JavaVMが解釈できるバイナリファイルであるクラスファイルにコンパイルする。JavaVMは、そのクラスファイルを解釈し、プログラムを実行する。   To run a Java program on JavaVM, first, source code written in the Java language is compiled into a class file that is a binary file that can be interpreted by JavaVM. JavaVM interprets the class file and executes the program.

バンドルは、クラスファイルや画像ファイル等のプログラムの実行に必要なファイルの集合である。OSGi仕様では、複数のバンドルが連携する仕組み、つまり、あるバンドルが提供するクラスファイルを別のバンドルが呼び出すことができる仕組みを定めている。   A bundle is a set of files necessary for executing a program such as a class file or an image file. The OSGi specification defines a mechanism in which a plurality of bundles cooperate, that is, a mechanism in which another bundle can call a class file provided by a bundle.

その1つがOSGiサービスによる連携である。具体的には、図17に示すように、バンドルAが、Javaインターフェイスで定義されるサービスSの実装クラスを提供し、生成したオブジェクトをOSGiサービスとしてOSGiFWのサービスレジストリに登録する。バンドルBは、サービスレジストリに登録されている当該OSGiサービスを取得し、そのオブジェクトが持つサービスSのメソッドを呼び出すことができる。   One of them is cooperation by OSGi service. Specifically, as shown in FIG. 17, the bundle A provides an implementation class of the service S defined by the Java interface, and registers the generated object as an OSGi service in the OSGiFW service registry. The bundle B can acquire the OSGi service registered in the service registry and call the service S method of the object.

その他、パッケージのImport・Exportによる連携などがある。   In addition, there is cooperation by Import / Export of packages.

〔機能の提供・利用について〕
多くのOSGiサービスは、図18に示すように、OSGiサービスを登録したバンドルCが、サービスSを通じてバンドルDに機能を提供する形態である。
[Providing and using functions]
In many OSGi services, as shown in FIG. 18, the bundle C in which the OSGi service is registered provides a function for the bundle D through the service S.

例えば、OSGi仕様で定められたHttpServiceでは、バンドルCがHttpServiceの実装クラスを提供してサービス登録することにより、HTTPサーバへのJavaServlet登録機能などを他のバンドルに提供する。バンドルDは、HttpServiceを取得し、呼び出すことにより、バンドルCが提供するクラスのHttpServiceの機能を利用する。   For example, in the HTTP Service defined by the OSGi specification, the bundle C provides an HTTP Service implementation class and performs service registration, thereby providing a Java Servlet registration function to an HTTP server to other bundles. The bundle D obtains and calls the HttpService to use the HttpService function of the class provided by the bundle C.

一方、コールバック型の呼び出しの場合、機能の提供と利用が逆になる。例として、図19に示すように、ある情報を管理するバンドルEと、その情報が変更された時点で通知して欲しいバンドルFが存在する場合における、イベント通知が挙げられる。   On the other hand, in the case of a callback type call, the provision and use of functions are reversed. As an example, as shown in FIG. 19, there is an event notification when there is a bundle E that manages certain information and a bundle F that is desired to be notified when the information is changed.

この場合、バンドルFが、イベントリスナLとなるOSGiサービスの実装クラスを提供してサービスレジストリにサービス登録し、バンドルEがイベント通知すべきタイミングになると、登録された当該OSGiサービスを取得してコールバックする。   In this case, the bundle F provides the OSGi service implementation class that becomes the event listener L, registers the service in the service registry, and when the bundle E is to notify the event, obtains the registered OSGi service and calls it. Back.

つまり、イベント通知という機能を提供するのは呼び出しを行うバンドルEであり、クラスを提供するバンドルFはその機能を利用していることになる。   That is, a function called event notification is provided by a bundle E that performs a call, and a bundle F that provides a class uses the function.

このような機能の提供・利用の関係は、バンドル同士の連携以外にも、バンドルとOSGiFW、バンドルとJavaVMなどにもある。   The relationship between the provision and use of such functions also exists in bundles and OSGiFW, bundles and JavaVM, etc., in addition to cooperation between bundles.

〔JavaVMについて〕
従来の技術では、バンドル・OSGiFW・JavaVM自体が動作するために必要なメモリは、JavaVMが、OSから割り当てられた1つのヒープメモリ(ヒープ領域)から確保する。具体的には、例えば、あるスレッドで呼び出されたバンドルが利用(確保・消費)するメモリは、1つのヒープ領域から確保される。以下、メモリ割当という表現で説明する場合もある。
[About JavaVM]
In the conventional technology, the memory required for the bundle, OSGiFW, and JavaVM itself to operate is secured by the JavaVM from one heap memory (heap area) allocated from the OS. Specifically, for example, a memory used (secured / consumed) by a bundle called by a certain thread is secured from one heap area. Hereinafter, it may be described by the expression of memory allocation.

また、JavaVM上で動作するスレッドにおいて、メモリ割当は、図20に示すように、常に、各スレッドの一番上のスタック(TOPSTACK)で発生する。JavaVM仕様としては、オブジェクトには特定の構造体を規定していない。システムのEntityであるバンドル・OSGiFW・JavaVMは、1つのヒープ領域を共有する。   Further, in a thread operating on JavaVM, memory allocation always occurs in the top stack (TOPSTACK) of each thread as shown in FIG. In the JavaVM specification, a specific structure is not defined for an object. Bundles, OSGiFW, and JavaVM, which are system entities, share one heap area.

メモリ割当時に必要なメモリ量が確保できないとGC(Garbage Collection)が行われ、その時点で参照されていないオブジェクトのメモリ領域は解放される。GCが行われても必要なメモリ量が確保できない場合には、OOM(Out Of Memory)エラーが発生する。OOMエラーを捕捉し、対処する処理が各Entityで適切にされていない場合、そのEntityは動作をしなくなる可能性がある。   If the memory amount necessary for memory allocation cannot be secured, GC (Garbage Collection) is performed, and the memory area of the object that is not referenced at that time is released. If the required amount of memory cannot be secured even after GC, an OOM (Out Of Memory) error occurs. If an OOM error is caught and handled, the entity may fail to operate if it is not appropriate for each entity.

本発明では、「必要なメモリ量が確保できない場合」とは、GCが行われても必要なメモリ量が確保できない場合を指す。   In the present invention, “the case where the necessary amount of memory cannot be secured” refers to the case where the necessary amount of memory cannot be secured even when GC is performed.

また、図21に示すように、JavaVMのスタック構造は、一般的に、(1)呼び出し元スタックによる呼び出しが契機になり、(2)クラス提供スタック内の処理においてメモリ割当が行われる。   As shown in FIG. 21, the JavaVM stack structure is generally (1) triggered by a call from the caller stack, and (2) memory allocation is performed in the processing in the class providing stack.

「The Java Virtual Machine Specification、3.5.3 Heap, 4.1 The ClassFile Structure」、[Online]、平成24年2月8日検索、<URL : http://java.sun.com/docs/books/jvms/second_edition/html/VMSpecTOC.doc.html>"The Java Virtual Machine Specification, 3.5.3 Heap, 4.1 The ClassFile Structure", [Online], searched February 8, 2012, <URL: http://java.sun.com/docs/books/jvms/ second_edition / html / VMSpecTOC.doc.html> 「OSGi Alliance」、[Online]、平成24年2月8日検索、<URL : http://www.osgi.org/Specifications/HomePage>"OSGi Alliance", [Online], searched February 8, 2012, <URL: http://www.osgi.org/Specifications/HomePage>

従来の技術では、バンドル・OSGiFW・JavaVMがヒープ領域を共有するため、あるEntityでOOMエラーが発生してメモリが解放されない場合、その他のEntityもその時点以降、新たにメモリを確保することができなくなり、結果的に全てのシステムが停止してしまう可能性がある。   In the conventional technology, the bundle, OSGiFW, and JavaVM share the heap area. If an OOM error occurs at a certain entity and the memory is not released, other entities can also secure new memory after that point. As a result, all the systems may stop.

特に課題となるのは、複数の事業者が従来の技術を用いて、1つのシステムを共有して同時にサービスを提供するような場合である。   A particular problem arises when a plurality of business operators share a single system and provide services simultaneously using conventional technology.

例えば、プラットフォーム(Platform)事業者(以下、「PF事業者」と称する)は、JavaVMやOSGiFWなどのシステムの基盤となる部分をプラットフォームシステムとして提供し、サービス(Service Provider)事業者(以下、「SP事業者」と称する)は、自身が開発したバンドルをPF事業者が提供するプラットフォームシステム上で動作させることでサービスを提供することを想定する。   For example, a platform provider (hereinafter referred to as a “PF provider”) provides a platform system part such as JavaVM and OSGiFW as a platform system, and a service provider (hereinafter referred to as “Service Provider” provider). It is assumed that the service provider provides a service by operating a bundle developed by the user on a platform system provided by the PF provider.

この時、あるSP事業者の作成するバンドルがバグ等により想定以上のメモリを消費すると、そのバグがなければ正常に動作可能であったはずのJavaVM、OSGiFW、および他のバンドルなどの他のEntityまで動作できなくなってしまう。つまり、正常な動作をしているはずのJavaVM上で動作する全てのEntity(PF事業者の提供するシステムやSP事業者のバンドル)が、1つのSP事業者のバンドルのバグによって動作不能になることが発生する。   At this time, if a bundle created by a certain SP provider consumes more memory than expected due to a bug, other entities such as JavaVM, OSGiFW, and other bundles that should have been able to operate normally without the bug. It becomes impossible to operate until. In other words, all the entities (systems provided by PF providers and SP provider bundles) that operate on JavaVM that should be operating normally become inoperable due to a bug in one SP provider bundle. It happens.

また、前述したように、OSGiにおいてはバンドルやOSGiFWなどの構成要素が連携している。連携した時に消費されるメモリは、「呼び出し元」と「クラス提供」とのどちらのメモリ消費量としてカウントするかといった定義は、OSGiやJavaの仕様では定められていない(非特許文献1、非特許文献2参照)。定義が決まっていないため、バンドルのメモリ消費量の計測もできない。   As described above, in OSGi, components such as a bundle and OSGiFW are linked. The definition of whether the memory consumed when linking is counted as “caller” or “provided by class” is not defined in the specifications of OSGi or Java (Non-Patent Document 1, Non-Patent Document 1, Patent Document 2). Since the definition is not fixed, the memory consumption of the bundle cannot be measured.

本発明は、上記課題を鑑みてなされたものであり、その課題とするところは、メモリ消費量を任意の単位で制限することを目的とする。   The present invention has been made in view of the above problems, and an object of the present invention is to limit memory consumption in an arbitrary unit.

第1の本発明に係るメモリ管理装置は、ソフトウェアプラットフォーム上で動作するバンドルが利用するメモリを管理するメモリ管理装置であって、メモリの管理単位でグループを作成し、グループ毎に利用できるメモリ量の制限値を設定し、前記バンドルをインストールする際に、当該バンドルのクラスローダオブジェクトに前記グループを設定する設定手段と、前記バンドルあるいは前記ソフトウェアプラットフォームのクラスローダオブジェクトがメモリを要求したときに、メモリを要求した前記バンドルあるいは前記ソフトウェアプラットフォームのクラスローダオブジェクトに設定されたグループを要求メモリ量のカウント先として選択する選択手段と、前記選択手段が選択したグループにすでに割り当てられたメモリの合計値であるメモリ消費量積算値に前記要求メモリ量を加えた予想積算値と当該グループに設定された制限値とを比較し、前記予想積算値が前記制限値以下の場合は、ヒープ領域から前記要求メモリ量のメモリを割り当てるとともに、当該グループの前記メモリ消費量積算値に前記要求メモリ量を加えて前記メモリ消費量積算値を更新し、前記予想積算値が前記制限値を超えた場合はエラーを発生する割当手段と、を有することを特徴とする。 A memory management device according to a first aspect of the present invention is a memory management device that manages memory used by a bundle operating on a software platform, and creates a group in memory management units, and the amount of memory that can be used for each group set the limit, when installing the bundle, and setting means for setting the group to the class loader object of the bundle, when the class loader object of the bundle or the software platform requests a memory, the memory selection means for selecting a group set to the class loader object of the bundle or the software platform which requested as a count which the request memory amount, a total value of memory already assigned to the group selected by the selecting unit An estimated integrated value obtained by adding the requested memory amount to the integrated memory consumption value and a limit value set for the group. If the estimated integrated value is equal to or less than the limit value, Allocates the amount of memory, adds the requested memory amount to the memory consumption integrated value of the group, updates the memory consumption integrated value, and generates an error if the expected integrated value exceeds the limit value And assigning means.

第2の本発明に係るメモリ管理方法は、ソフトウェアプラットフォーム上で動作するバンドルが利用するメモリを管理するメモリ管理方法であって、コンピュータによる、メモリの管理単位でグループを作成し、グループ毎に利用できるメモリ量の制限値を設定するステップと、前記バンドルをインストールする際に、当該バンドルのクラスローダオブジェクトに前記グループを設定するステップと、前記バンドルあるいは前記ソフトウェアプラットフォームのクラスローダオブジェクトがメモリを要求したときに、メモリを要求した前記バンドルあるいは前記ソフトウェアプラットフォームのクラスローダオブジェクトに設定されたグループを要求メモリ量のカウント先として選択するステップと、前記選択するステップで選択したグループにすでに割り当てられたメモリの合計値であるメモリ消費量積算値に前記要求メモリ量を加えた予想積算値と当該グループに設定された制限値とを比較するステップと、前記予想積算値が前記制限値以下の場合は、ヒープ領域から前記要求メモリ量のメモリを割り当てるとともに、当該グループの前記メモリ消費量積算値に前記要求メモリ量を加えて前記メモリ消費量積算値を更新するステップと、前記予想積算値が前記制限値を超えた場合は、エラーを発生するステップと、を有することを特徴とする。 A memory management method according to a second aspect of the present invention is a memory management method for managing a memory used by a bundle operating on a software platform, wherein a group is created by a memory management unit by a computer and used for each group. Setting a limit value of the amount of memory that can be created; setting the group in the class loader object of the bundle when installing the bundle; and the class loader object of the bundle or the software platform requested memory Occasionally, the step of selecting the bundle or group set to the class loader object of the software platform which requested the memory as the count which the request amount of memory, glue selected in said selecting step Comparing a predicted integrated value obtained by adding the requested memory amount to a memory consumption integrated value that is a total value of memory already allocated to the limit value set for the group, and the predicted integrated value is the limit value If less than the value, allocating the required memory amount from the heap area, adding the required memory amount to the memory consumption integrated value of the group, and updating the memory consumption integrated value; and A step of generating an error when the integrated value exceeds the limit value.

上記メモリ管理方法において、前記バンドルあるいは前記ソフトウェアプラットフォームのクラスローダオブジェクトがメモリを要求したときに、メモリを要求した前記バンドルあるいは前記ソフトウェアプラットフォームの呼び出し元を辿り、最初の呼び出し元となるバンドルあるいは前記ソフトウェアプラットフォームが属するグループを要求メモリ量のカウント先として選択することを特徴とする。 In the memory management method, when a class loader object of the bundle or the software platform requests a memory, the bundle or software platform that is the first caller is traced by calling the bundle or software platform that requested the memory. A group to which the platform belongs is selected as a count destination of the requested memory amount .

上記メモリ管理方法において、前記バンドルあるいは前記ソフトウェアプラットフォームのクラスローダオブジェクトがメモリを要求したときに、メモリを要求した前記バンドルあるいは前記ソフトウェアプラットフォームの呼び出し元を辿り、前記ソフトウェアプラットフォームに呼び出されたバンドルが属するグループを要求メモリ量のカウント先として選択することを特徴とする。 In the memory management method described above, when the class loader object of the bundle or the software platform requests a memory, the bundle or the software platform that requested the memory is traced, and the bundle called by the software platform belongs. A group is selected as a count destination of the requested memory amount .

上記メモリ管理方法において、前記バンドルに機能提供フラグあるいは機能利用フラグを設定しておき、前記バンドルあるいは前記ソフトウェアプラットフォームのクラスローダオブジェクトがメモリを要求したときに、メモリを要求した前記バンドルあるいは前記ソフトウェアプラットフォームの呼び出し元を辿り、前記ソフトウェアプラットフォームに呼び出されたバンドルが属するグループ、又は、機能利用フラグが設定されたバンドルが属するグループを要求メモリ量のカウント先として選択することを特徴とする。 In the memory management method, when the function providing flag or the function use flag is set in the bundle, and the class loader object of the bundle or the software platform requests the memory, the bundle or the software platform that requested the memory And the group to which the bundle called by the software platform belongs or the group to which the bundle for which the function use flag is set belongs is selected as the requested memory amount count destination .

上記メモリ管理方法において、前記バンドルあるいは前記ソフトウェアプラットフォームがスレッドを立てるときに、当該スレッドを立てる前記バンドルあるいは前記ソフトウェアプラットフォームの属するグループを当該スレッドに設定しておき、前記バンドルあるいは前記ソフトウェアプラットフォームのクラスローダオブジェクトがメモリを要求したときに、メモリを要求した前記バンドルあるいは前記ソフトウェアプラットフォームが属するスレッドに設定されたグループを要求メモリ量のカウント先として選択することを特徴とする。
In the memory management method, when the bundle or the software platform sets up a thread, a group to which the bundle or the software platform that sets up the thread belongs is set to the thread, and the class loader of the bundle or the software platform is set. When an object requests a memory, a group set to a thread to which the bundle or the software platform to which the memory is requested belongs is selected as a count destination of the requested memory amount .

上記メモリ管理方法において、メモリが要求されて生成されたオブジェクトに、当該メモリの消費量のカウント先として選択されたグループを識別するグループIDを付与するステップと、指定されたグループIDが付与された前記オブジェクトのサイズを合計し、当該グループIDが示すグループのメモリ消費量を求めるステップと、を有することを特徴とする。   In the above memory management method, a step of assigning a group ID for identifying a group selected as a counting destination of consumption of the memory to an object generated when the memory is requested, and a specified group ID are given And summing up the sizes of the objects to obtain the memory consumption of the group indicated by the group ID.

第3の本発明に係るメモリ管理プログラムは、上記メモリ管理方法の各ステップをコンピュータに実行させることを特徴とする。   A memory management program according to a third aspect of the present invention causes a computer to execute each step of the memory management method.

本発明によれば、メモリ消費量を任意の単位で制限することができる。   According to the present invention, the memory consumption can be limited in an arbitrary unit.

本実施の形態におけるメモリ管理装置の構成を示す図である。It is a figure which shows the structure of the memory management apparatus in this Embodiment. 象限a〜dの呼び出し関係を示す表である。It is a table | surface which shows the calling relationship of the quadrants ad. グループ選択アルゴリズム説明時に参照されるスタックの例を示す図である。It is a figure which shows the example of the stack referred at the time of group selection algorithm description. 第1グループ選択アルゴリズムの動作を示すフローチャートである。It is a flowchart which shows operation | movement of a 1st group selection algorithm. 第1グループ選択アルゴリズム実行時の各スタックのリソース消費量の割り当て状況を示す図である。It is a figure which shows the allocation condition of the resource consumption of each stack at the time of 1st group selection algorithm execution. 第2グループ選択アルゴリズムの動作を示すフローチャートである。It is a flowchart which shows operation | movement of a 2nd group selection algorithm. 第2グループ選択アルゴリズム実行時の各スタックのリソース消費量の割り当て状況を示す図である。It is a figure which shows the allocation condition of the resource consumption of each stack at the time of 2nd group selection algorithm execution. 第3グループ選択アルゴリズムの動作を示すフローチャートである。It is a flowchart which shows operation | movement of a 3rd group selection algorithm. 象限a〜dの呼び出し関係とメモリ消費量のカウント先を示す表である。It is a table | surface which shows the call destination of quadrant ad, and the count destination of memory consumption. 第3グループ選択アルゴリズム実行時の各スタックのリソース消費量の割り当て状況を示す図である。It is a figure which shows the allocation condition of the resource consumption of each stack at the time of 3rd group selection algorithm execution. 第4グループ選択アルゴリズムの動作を示すフローチャートである。It is a flowchart which shows operation | movement of a 4th group selection algorithm. 象限a〜dの呼び出し関係とメモリ消費量のカウント先を示す表である。It is a table | surface which shows the call destination of quadrant ad, and the count destination of memory consumption. 第4グループ選択アルゴリズム実行時の各スタックのリソース消費量の割り当て状況を示す図である。It is a figure which shows the allocation condition of the resource consumption of each stack at the time of 4th group selection algorithm execution. PFセットの呼び出し関数の一例を示す図である。It is a figure which shows an example of the calling function of PF set. 第5グループ選択アルゴリズムの動作を示すフローチャートである。It is a flowchart which shows operation | movement of a 5th group selection algorithm. OSGiのシステムアーキテクチャを示す図である。It is a figure which shows the system architecture of OSGi. OSGiサービスによるバンドル間の連携を示す図である。It is a figure which shows the cooperation between bundles by an OSGi service. バンドル機能の提供・利用を示す図である。It is a figure which shows provision and utilization of a bundle function. バンドル機能の利用・提供を示す図である。It is a figure which shows utilization and provision of a bundle function. メモリ割当を説明する図である。It is a figure explaining memory allocation. JavaVMのスタック構造を説明する図である。It is a figure explaining the stack structure of JavaVM.

以下、本発明を実施する一実施の形態について図面を用いて説明する。但し、本発明は多くの異なる様態で実施することが可能であり、本実施の形態の記載内容に限定して解釈すべきではない。   Hereinafter, an embodiment for carrying out the present invention will be described with reference to the drawings. However, the present invention can be implemented in many different modes and should not be construed as being limited to the description of the present embodiment.

〔メモリ管理装置の構成について〕
まず、本実施の形態におけるメモリ管理装置1の構成について説明する。
[Configuration of memory management device]
First, the configuration of the memory management device 1 in the present embodiment will be described.

図1は、メモリ管理装置1の構成を示す図である。メモリ管理装置1は、演算処理装置、記憶装置等を備えたコンピュータにより構成して、各部の処理がプログラムによって実行されるものとする。このプログラムはメモリ管理装置1が備える記憶装置に記憶されており、磁気ディスク、光ディスク、半導体メモリ等の記録媒体に記録することも、ネットワークを通して提供することも可能である。   FIG. 1 is a diagram illustrating a configuration of the memory management device 1. The memory management device 1 is configured by a computer including an arithmetic processing device, a storage device, and the like, and the processing of each unit is executed by a program. This program is stored in a storage device included in the memory management device 1, and can be recorded on a recording medium such as a magnetic disk, an optical disk, or a semiconductor memory, or provided through a network.

本実施の形態におけるメモリ管理装置1は、OS上で動作するJavaVM10と、JavaVM10上でバンドルの実行環境を提供するOSGiFW11と、OSGiFW11上でJavaプログラムとして動作するリソース管理バンドル12aとで構成され、JavaVM10とOSGiFW11で構成されたソフトウェアプラットフォーム上で動作するバンドルが利用(確保・消費)するリソースを管理する装置である。   The memory management device 1 according to the present embodiment includes a Java VM 10 that operates on the OS, an OSGiFW 11 that provides a bundle execution environment on the Java VM 10, and a resource management bundle 12a that operates as a Java program on the OSGiFW 11, and the Java VM 10 And a resource that is used (secured / consumed) by a bundle operating on a software platform configured with OSGiFW11.

PF事業者が作成するバンドルをオーナーバンドル12とし、SP事業者がサービスを提供するために作成するバンドルをSPバンドル131とする。また、1以上のバンドルで構成されるバンドル群をバンドルセットとし、SP事業者が作成するバンドルセットをSPバンドルセット13、PF事業者がプラットフォームシステムとして作成する、JavaVM10、OSGiFW11、およびオーナーバンドル12をPFセット14とする。PFセット14は本実施の形態において1つであり、SPバンドルセット13は複数考えられる。   A bundle created by the PF company is referred to as an owner bundle 12, and a bundle created by the SP company for providing a service is referred to as an SP bundle 131. In addition, a bundle group composed of one or more bundles is used as a bundle set, a bundle set created by an SP provider is created as an SP bundle set 13, and a Java VM 10, OSGiFW 11, and owner bundle 12 are created as a platform system by a PF provider. The PF set 14 is assumed. There is one PF set 14 in the present embodiment, and a plurality of SP bundle sets 13 can be considered.

JavaVM10は、OSから受け取ったリソースを用いて、OSGiFW11、オーナーバンドル12、およびSPバンドル131などのソフトウェアを動作させる。本実施の形態におけるJavaVM10は、独自の改造部を有し、ソフトウェアを動作させるにあたって、リソースを管理する単位であるグループを作成してグループIDを付与し、グループ毎にメモリ消費量の制限値を設定してメモリ消費量を管理する。   The Java VM 10 operates software such as the OSGiFW 11, the owner bundle 12, and the SP bundle 131 using resources received from the OS. The Java VM 10 according to the present embodiment has a unique remodeling unit, and when operating the software, creates a group that is a unit for managing resources, assigns a group ID, and sets a memory consumption limit value for each group. Set to manage memory consumption.

また、クラスローダオブジェクトによりクラスがロードされてオブジェクトが生成される際に割り当てられるメモリをどのグループのメモリ消費量としてカウントするかを判定し、メモリ消費量をカウントするグループのメモリ消費量の合計が制限値を超えた場合にはエラーを発生させる。割り当てるメモリの消費量をどのグループのメモリ消費量としてカウントするかを判定するグループ選択アルゴリズムは任意に定めることができる。グループ選択アルゴリズムを変えることによって、どの単位でメモリ消費量を制限できるかが変化する。グループ選択アルゴリズムの具体例については後述する。   Also, it is determined which group memory consumption is counted as the memory allocated when the class is loaded and the object is generated by the class loader object, and the total memory consumption of the group for which the memory consumption is counted is An error is generated if the limit value is exceeded. A group selection algorithm for determining which group's memory consumption is to be counted as the memory consumption of which group can be arbitrarily determined. Changing the group selection algorithm changes in which units the memory consumption can be limited. A specific example of the group selection algorithm will be described later.

これらの機能を実現するために、JavaVM10は、クラスローダオブジェクトにグループIDを設定できるデータ構造、オブジェクト毎に、そのオブジェクトが属するグループIDを保持するデータ構造、および、グループ毎に、そのグループのメモリ消費量としてカウントされたメモリ消費量を合計したメモリ消費量積算値とそのグループに設定されたメモリ消費量の制限値を保持する領域を持つ。また、JavaVM10は、これらを設定するためのAPIを備える。   In order to realize these functions, the Java VM 10 has a data structure in which a group ID can be set for a class loader object, a data structure for holding a group ID to which the object belongs, and a memory of the group for each group. It has an area for holding a memory consumption integrated value obtained by summing up memory consumption counted as consumption and a memory consumption limit value set for the group. In addition, the Java VM 10 includes an API for setting these.

OSGiFW11は、バンドルのインストール、バンドル間の連携機能などをサポートする。本実施の形態におけるOSGiFW11は、SPバンドル131がインストールされた際に、リソース管理バンドル12aに対してResolvedイベントを一番最初にコールバックする独自の改造部を有する。   The OSGiFW 11 supports bundle installation, a cooperation function between bundles, and the like. The OSGiFW 11 according to the present embodiment has a unique remodeling unit that first calls back a Resolved event to the resource management bundle 12a when the SP bundle 131 is installed.

リソース管理バンドル12aは、オーナーバンドル12の一つであり、SPバンドルセット13毎にグループIDを割り振ってメモリ消費量の制限値をJavaVM10に設定し、SPバンドル131がインストールされた際に、インストールされたSPバンドル131のクラスローダオブジェクトにグループIDを設定する。具体的には、リソース管理バンドル12aは、1つのSPバンドルセット13を構成するSPバンドル131の情報(以下、「バンドルセット情報」と称する)とSPバンドルセット13に利用許可されるメモリ量(以下、「バンドルセットメモリ量」と称する)を入手し、入手したバンドルセット情報にJavaVM10から得たグループIDを関連付け、グループIDとバンドルセットメモリ量をJavaVM10に対して通知し、バンドルセットメモリ量をそのグループのメモリ消費量の制限値として設定する。   The resource management bundle 12a is one of the owner bundles 12, and is installed when the SP bundle 131 is installed by allocating a group ID for each SP bundle set 13 and setting a memory consumption limit value in the Java VM 10. The group ID is set in the class loader object of the SP bundle 131. Specifically, the resource management bundle 12a includes information on the SP bundle 131 that constitutes one SP bundle set 13 (hereinafter referred to as “bundle set information”) and the amount of memory permitted to be used by the SP bundle set 13 (hereinafter referred to as “bundle set information”). , Referred to as “bundle set memory amount”), associate the group ID obtained from the Java VM 10 with the obtained bundle set information, notify the Java VM 10 of the group ID and the bundle set memory amount, and determine the bundle set memory amount Set as a limit value for group memory consumption.

また、SPバンドル131がインストールされてリソース管理バンドル12aがResolvedイベントを受信した際に、インストールされたSPバンドル131のクラスローダオブジェクトをJava/OSGiの標準APIを通じて取得し、SPバンドル131のクラスローダオブジェクトとそのSPバンドル131が属するSPバンドルセット13に関連付けたグループIDを組みにした情報をJavaVM10に通知し、SPバンドル131のクラスローダオブジェクトにグループIDを設定する。   Further, when the SP bundle 131 is installed and the resource management bundle 12a receives the Resolved event, the class loader object of the installed SP bundle 131 is acquired through the standard API of Java / OSGi, and the class loader object of the SP bundle 131 is acquired. The Java VM 10 is notified of the information including the group ID associated with the SP bundle set 13 to which the SP bundle 131 belongs, and the group ID is set in the class loader object of the SP bundle 131.

バンドルセット情報とは、OSGi仕様で定められるBundle−SymbolicNameとBundle−Versionとによってバンドルを一意に識別した識別子であり、識別したSPバンドル131が1つ以上指定される。バンドルセット情報とバンドルセットメモリ量は、メモリ管理装置1とは別装置として外部に設置されたサーバ3から入手する。バンドルセット情報等の受け渡しはXMLファイル等の様々な方法が考えられる。なお、バンドルセット情報等については、メモリ管理装置1自身の記憶手段に予め保持しておいてもよい。   The bundle set information is an identifier that uniquely identifies the bundle by the Bundle-SymbolicName and Bundle-Version defined by the OSGi specification, and one or more identified SP bundles 131 are designated. The bundle set information and the bundle set memory amount are obtained from a server 3 installed outside as a device separate from the memory management device 1. Various methods such as an XML file can be considered for delivery of bundle set information and the like. Note that the bundle set information and the like may be stored in advance in the storage unit of the memory management device 1 itself.

〔メモリ管理装置の動作について〕
次に、メモリ管理装置1の動作について説明する。
[Operation of memory management device]
Next, the operation of the memory management device 1 will be described.

以下、メモリ管理装置1が行う、リソースを管理する単位であるグループを作成してグループ毎にメモリ消費量の制限値を設定する処理と、クラスをロードしてオブジェクトを生成する際にメモリを割り当てる処理について説明する。   The memory management device 1 performs a process for creating a group, which is a unit for managing resources, and sets a memory consumption limit value for each group, and allocates a memory when a class is loaded to generate an object. Processing will be described.

まず、グループを作成してグループ毎にメモリ消費量の制限値を設定する処理について説明する。   First, processing for creating a group and setting a memory consumption limit value for each group will be described.

リソース管理バンドル12aは、通信ネットワークを介して接続された外部のサーバ3から、バンドルセット情報とバンドルセットメモリ量とを取得しておく。   The resource management bundle 12a acquires bundle set information and a bundle set memory amount from an external server 3 connected via a communication network.

SPバンドル131がOSGiFW11にインストールされ、リソース管理バンドル12aがOSGiFW11からResolvedイベントを受信すると、インストールされたSPバンドル131の属するSPバンドルセット13に関連付けるグループIDをJavaVM10から取得する。このとき、JavaVM10は、新規にグループを作成してグループIDを付与し、グループIDをリソース管理バンドル12aに返信する。   When the SP bundle 131 is installed in the OSGiFW 11 and the resource management bundle 12a receives the Resolved event from the OSGiFW 11, the group ID associated with the SP bundle set 13 to which the installed SP bundle 131 belongs is acquired from the Java VM 10. At this time, the Java VM 10 newly creates a group, assigns a group ID, and returns the group ID to the resource management bundle 12a.

そして、リソース管理バンドル12aは、インストールされたSPバンドル131のクラスローダオブジェクトを取得し、取得したクラスローダオブジェクトと上記のグループIDをJavaVM10に通知する。JavaVM10は、通知されたクラスローダオブジェクトにグループIDを設定する。   Then, the resource management bundle 12a acquires the class loader object of the installed SP bundle 131, and notifies the Java VM 10 of the acquired class loader object and the above group ID. The Java VM 10 sets a group ID for the notified class loader object.

また、リソース管理バンドル12aは、上記のグループIDとインストールされたSPバンドル131のSPバンドルセット13のバンドルセットメモリ量をJavaVM10に通知する。JavaVM10は、通知されたグループIDに通知されたバンドルセットメモリ量をメモリ消費量の制限値として設定する。   In addition, the resource management bundle 12a notifies the Java VM 10 of the group ID and the bundle set memory amount of the SP bundle set 13 of the installed SP bundle 131. The Java VM 10 sets the bundle set memory amount notified to the notified group ID as a memory consumption limit value.

OSGiFW11は、SPバンドル131がインストールされた際、一番最初にリソース管理バンドル12aをコールバックするので、インストールされたSPバンドル131がリソース確保を行う前にグループIDを設定できる。   When the SP bundle 131 is installed, the OSGiFW 11 calls back the resource management bundle 12a first, so that the group ID can be set before the installed SP bundle 131 secures resources.

続いて、生成されるオブジェクトにメモリを割り当てる処理について説明する。   Next, a process for allocating memory to the generated object will be described.

クラスローダオブジェクトによりクラスがロードされてオブジェクトが生成されるときには、後述するグループ選択アルゴリズムによって、オブジェクトの呼び出し関係に基づいてグループが選択され、生成されるオブジェクトにグループIDが設定される。オブジェクトを生成するために必要なメモリを割り当てる際に、設定されたグループIDについて、そのグループのメモリ消費量の合計が制限値を超えないかチェックを行う。以下、メモリ消費量のチェックの方法について説明する。   When a class is loaded by a class loader object and an object is generated, a group selection algorithm, which will be described later, selects a group based on the object calling relationship, and sets a group ID for the generated object. When allocating a memory necessary for generating an object, it is checked whether or not the total memory consumption of the group exceeds the limit value for the set group ID. Hereinafter, a method of checking the memory consumption will be described.

選択されたグループのメモリ消費量積算値に生成されるオブジェクトのサイズを加算した値が、グループのメモリ消費量の制限値以下の場合は、メモリの割り当ては成功とし、メモリ消費量積算値にオブジェクトのサイズを加算してメモリ消費量積算値を更新し、ヒープ領域からオブジェクトのサイズ分のメモリを割り当ててオブジェクトを生成する。   If the value obtained by adding the generated object size to the memory consumption integrated value of the selected group is less than or equal to the memory consumption limit value of the group, the memory allocation is successful, and the object is added to the memory consumption integrated value. The memory consumption integrated value is updated by adding the size of the memory, and an object corresponding to the size of the object is allocated from the heap area to generate the object.

選択されたグループのメモリ消費量積算値に生成されるオブジェクトのサイズを加算した値が、グループのメモリ消費量の制限値より大きい場合は、GCを実行し、参照されていないオブジェクトのメモリを解放した後、選択されたグループのGC後のメモリ消費量積算値に生成されるオブジェクトのサイズを加算してメモリを割り当てるか否か判定する。GCを実行してもメモリ消費量積算値にオブジェクトのサイズを加算した値がメモリ消費量の制限値を超える場合は、OOMエラーを発生させる。メモリ消費量積算値にオブジェクトのサイズを加算した値がメモリ消費量の制限値以下の場合は、メモリの割り当ては成功とし、GC後のメモリ消費量積算値にオブジェクトのサイズを加算してメモリ消費量積算値を更新し、ヒープ領域からオブジェクトのサイズ分のメモリを割り当ててオブジェクトを生成する。   If the value obtained by adding the size of the generated object to the integrated memory consumption value of the selected group is larger than the limit value of the memory consumption of the group, execute GC and release the memory of the unreferenced object After that, it is determined whether to allocate memory by adding the size of the generated object to the memory consumption integrated value after GC of the selected group. If the value obtained by adding the object size to the memory consumption integrated value exceeds the memory consumption limit value even after the GC is executed, an OOM error is generated. If the value obtained by adding the object size to the memory consumption integrated value is less than or equal to the memory consumption limit value, the memory allocation is successful, and the memory size is calculated by adding the object size to the memory consumption integrated value after GC. The amount integrated value is updated, and an object corresponding to the size of the object is allocated from the heap area to generate the object.

以上説明したように、本実施の形態によれば、1以上のSPバンドル131で構成されるバンドル群をSPバンドルセット13とし、SPバンドルセット13毎にグループを構成してグループIDを付与し、グループ毎にメモリ消費量積算値をカウントするとともに、グループ毎にメモリ消費量の制限値を設定することにより、グループ毎にメモリ消費量を任意の単位で制限することが可能となる。   As described above, according to the present embodiment, a bundle group composed of one or more SP bundles 131 is set as an SP bundle set 13, a group is formed for each SP bundle set 13, and a group ID is assigned. By counting the memory consumption integrated value for each group and setting a memory consumption limit value for each group, it becomes possible to limit the memory consumption for each group in an arbitrary unit.

グループ毎のメモリ消費量の制限を値ではなく、実際にグループ毎にヒープ領域を分割して複数保持する方法も考えられる。しかしながら、この方法では、グループ毎のヒープ領域の割り当てサイズを変更する際にヒープ領域の再構成が必要となり、既にヒープ領域に確保したオブジェクトの移動が発生する可能性がある。そのため、JavaVM起動中に柔軟に分割したヒープ領域を変更することは困難である。本実施の形態では、グループ毎のメモリ消費量の制限を制限値として単に値で保持しているので、メモリ割り当て時にメモリ消費量が制限値を超えるか否か参照するだけで済み、さらに、ヒープ領域に確保したオブジェクトの移動を発生させることなく、グループ毎の制限値を柔軟に変更することができる。   A method of storing a plurality of heap areas by actually dividing the heap area for each group instead of the value of the memory consumption limit for each group is also conceivable. However, in this method, when changing the allocation size of the heap area for each group, it is necessary to reconfigure the heap area, and there is a possibility that an object already secured in the heap area may move. For this reason, it is difficult to change the heap area that is flexibly divided during JavaVM activation. In this embodiment, since the memory consumption limit for each group is simply held as a limit value, it is only necessary to refer to whether or not the memory consumption exceeds the limit value when allocating memory. The limit value for each group can be flexibly changed without causing the movement of the object secured in the area.

なお、上記では、SPバンドルセット13のメモリ消費量を制限することについて説明したが、もちろんPFセット14にも同様にグループIDを付与してメモリ消費量を制限することも可能である。   In the above description, the memory consumption amount of the SP bundle set 13 is limited. However, it is possible to restrict the memory consumption amount by assigning a group ID to the PF set 14 as well.

また、上記では、SPバンドル131について説明したが、オーナーバンドル12がインストールされた場合についても同様に適用可能である。   In the above description, the SP bundle 131 has been described. However, the present invention is also applicable to the case where the owner bundle 12 is installed.

〔グループ選択アルゴリズム〕
次に、グループ選択アルゴリズムについて説明する。
[Group selection algorithm]
Next, the group selection algorithm will be described.

メモリの割り当てを行う際、割り当てるメモリの消費量をカウントするグループを選択するアルゴリズムを変えることによって、どの単位(例えば、スレッド単位、バンドル単位など)でメモリ消費量を制限できるかが変化することになる。本実施の形態では、一例として、4つのグループ選択アルゴリズムについて説明する。   When allocating memory, changing the algorithm that selects the group that counts the amount of memory to be allocated changes the unit in which memory consumption can be limited (for example, thread unit, bundle unit, etc.) Become. In this embodiment, four group selection algorithms will be described as an example.

ここで、PFセットとSPバンドルセットとの関係性を考える。PFセットとSPバンドルセットとのどちらがクラス提供側・呼び出し元になるのかは、以下の4通り(2×2通り)が考えられる。   Here, the relationship between the PF set and the SP bundle set is considered. The following 4 types (2 × 2 types) can be considered as which of the PF set and the SP bundle set is the class provider / caller.

象限a)クラス提供側:PFセット 呼び出し元 :PFセット
象限b)クラス提供側:PFセット 呼び出し元 :SPバンドルセットY
象限c)クラス提供側:SPバンドルセットX 呼び出し元 :PFセット
象限d)クラス提供側:SPバンドルセットX 呼び出し元 :SPバンドルセットY
なお、象限bと象限cについては、PFセットにとってはいずれもSPバンドルセットであるので、SPバンドルセットはSPバンドルセットX(SP_X)でもSPバンドルセットY(SP_Y)でも良いが、ここではクラス提供側をSP_X、呼び出し元をSP_Yとして便宜上区別している。
Quadrant a) Class provider: PF set Caller: PF set Quadrant b) Class provider: PF set Caller: SP bundle set Y
Quadrant c) Class provider: SP bundle set X Caller: PF set Quadrant d) Class provider: SP bundle set X Caller: SP bundle set Y
Since quadrant b and quadrant c are both SP bundle sets for the PF set, the SP bundle set may be SP bundle set X (SP_X) or SP bundle set Y (SP_Y). The side is SP_X and the caller is SP_Y for the sake of convenience.

図2は、上記の各象限について呼び出し関係を示す表である。表の内部は、呼び出し元のスタックとクラス提供側のスタックを表しており、下の枠が呼び出し元のスタック、上の枠がクラス提供側のスタックを示す。   FIG. 2 is a table showing the calling relationship for each quadrant. The inside of the table shows the caller's stack and the class provider's stack, with the lower frame showing the caller's stack and the upper frame showing the class provider's stack.

図3は、後述するグループ選択アルゴリズムの説明時に参照されるスタックの例を示す図であり、JavaVM10が実行するあるスレッドについて、一番下のスタックをスタック[0]のPFセットのスタックとして積み重なった様子を示す。図3中の枠内の数字が各スタックの番号を示し、番号順に呼び出されたものである。また、枠内の文字が各スタックを作成したクラスの提供元を示す。図3中の枠外の上向き矢印は、呼び出しの流れを示し、矢印横のa〜dは、呼び出し関係がどの象限に該当するのかを示している。例えば、スタック[0]のPFセットのクラスがスタック[1]のSPバンドルセット1(以下、「SP_BS1」と称する)のクラスを呼び出している。この場合、PFセットが呼び出し元でSP_BS1がクラス提供側となるので、象限cに該当する。なお、後述の具体例では、図3の枠外右側の○印から矢印を延ばしてメモリ消費量のカウント先を示す。   FIG. 3 is a diagram illustrating an example of a stack referred to when a group selection algorithm described later is described. For a certain thread executed by the Java VM 10, the bottom stack is stacked as a stack of the PF set of the stack [0]. Show the state. The numbers in the frame in FIG. 3 indicate the numbers of the respective stacks, which are called in order of numbers. The characters in the frame indicate the provider of the class that created each stack. The upward arrow outside the frame in FIG. 3 indicates the flow of the call, and ad next to the arrow indicate which quadrant the call relationship corresponds to. For example, the class of the PF set of the stack [0] calls the class of the SP bundle set 1 (hereinafter referred to as “SP_BS1”) of the stack [1]. In this case, since the PF set is the caller and SP_BS1 is the class providing side, this corresponds to quadrant c. In the specific example described later, an arrow is extended from the circle mark on the right side outside the frame in FIG. 3 to indicate the memory consumption count destination.

以下、グループ選択アルゴリズムを説明する前に、用語の定義を行う。定数を大文字、変数の頭文字は小文字で表す。ここでの定数は、1回のグループ選択アルゴリズムの処理において変化しない値を指す。グループIDを意味する定数としては、PFセットのクラスローダオブジェクトに設定されているグループIDを示すGROUPID_PF、各スタックにて処理が行われるクラスのクラスローダオブジェクトに設定されているグループIDを示すSTACK_GROUPIDがある。グループIDを代入する変数としては、最終的にメモリ消費量をカウントするグループを示す変数groupID、groupIDを決定するために一時的に利用するcurGroupIDがある。また、各スレッドの一番上のスタックをTOPSTACKとし、呼び出し元として処理中のスタックを指す変数をcurStackとする。以下で説明するグループ選択アルゴリズムは、curStackをTOPSTACKから順に下まで辿って処理を行うが、一番下のスタック[0]の次を指定した場合、curStackはNullを指すものとする。   Hereinafter, terms will be defined before explaining the group selection algorithm. Express constants in uppercase and variable initials in lowercase. The constant here refers to a value that does not change in a single group selection algorithm process. As constants indicating the group ID, there are GROUPID_PF indicating the group ID set in the class loader object of the PF set, and STACK_GROUP ID indicating the group ID set in the class loader object of the class to be processed in each stack. is there. As variables for substituting the group ID, there are a variable groupID and a groupID that are temporarily used to determine a groupID indicating a group for finally counting the memory consumption. Also, let the top stack of each thread be TOPSTACK, and the variable indicating the stack being processed as the caller be curStack. In the group selection algorithm described below, curStack is traced down to TOPSTACK in order, and when the next of the bottom stack [0] is specified, curStack indicates Null.

メモリの割り当てはスレッドの一番上のスタックで実行されるので、グループ選択アルゴリズムは、常にTOPSTACKにおいてメモリの割り当てが必要となる度に実行される。   Since the memory allocation is performed on the top stack of the thread, the group selection algorithm is always executed every time memory allocation is required in TOPSTACK.

以下、各グループ選択アルゴリズムについて説明する。なお、以下説明する全てのグループ選択アルゴリズムの主体は、JavaVM10である。   Hereinafter, each group selection algorithm will be described. The subject of all the group selection algorithms described below is JavaVM10.

<第1グループ選択アルゴリズム>
第1グループ選択アルゴリズムの動作を示すフローチャートを図4に示す。
<First group selection algorithm>
A flowchart showing the operation of the first group selection algorithm is shown in FIG.

第1グループ選択アルゴリズムでは、TOPSTACKのSTACK_GROUPIDをgroupIDとする(S101)。   In the first group selection algorithm, the STACK_GROUPID of TOPSTACK is set to groupID (S101).

すなわち、図5に示すように、各スタックのクラスのメモリ消費量を、各スタックのクラスに対してそれぞれ設定されたグループでカウントする。   That is, as shown in FIG. 5, the memory consumption of each stack class is counted in a group set for each stack class.

以上より、各スタックのクラスのメモリ消費量を、各スタックのクラスに対してそれぞれ設定されたグループに割り当てるので、呼び出し元に関わらず、実装クラスのセット(PFセットやSPバンドルセット)単位でメモリ消費量を制限できる。   As described above, the memory consumption of each stack class is allocated to the group set for each stack class, so the memory is set for each set of implementation classes (PF set and SP bundle set) regardless of the caller. The consumption can be limited.

<第2グループ選択アルゴリズム>
第2グループ選択アルゴリズムの動作を示すフローチャートを図6に示す。第2グループ選択アルゴリズムは、スタックを1つずつ下に辿り、最初の呼び出し元となるスタックを探索するアルゴリズムである。
<Second group selection algorithm>
A flowchart showing the operation of the second group selection algorithm is shown in FIG. The second group selection algorithm is an algorithm for tracing down the stack one by one and searching for the first caller stack.

curStackにTOPSTACKを代入し(S201)、curStackが一番下のスタックを指すまで、curStackを1つずつ下のスタックにずらしていく(S202,S203)。   TOPSTACK is assigned to curStack (S201), and curStack is shifted one by one to the lower stack until curStack points to the bottom stack (S202, S203).

そして、curStackのSTACK_GROUPIDをgroupIDとする(S204)。   Then, STACK_GROUPID of curStack is set to groupID (S204).

すなわち、全てのスタックのメモリ消費量を、最初に呼び出しを行ったスタック[0]のクラスに対して設定されたグループに割り当てるようにしている。   That is, the memory consumption of all stacks is assigned to the group set for the class of stack [0] that is first called.

図7に、第2グループ選択アルゴリズムを実行した際の各スタックのメモリ消費量の割り当て状況を示す。図7に示すように、あるスレッドの全てのスタックのメモリ消費量は、一番下のスタック[0]に割り当てられる。ここで、スタック[6]のメモリ消費量がどのようにカウントされるかを説明する。スタック[6]を呼び出したのはスタック[5]であり、スタック[5]を呼び出したのはスタック[4]である。スタック[4]を呼び出したのはスタック[3]であり、スタック[3]を呼び出したのはスタック[2]である。スタック[2]を呼び出したのはスタック[1]であり、スタック[1]を呼び出したのはスタック[0]である。スタック[0]には呼び出し元がないため、結果的にスタック[6]のメモリ消費量は、スタック[0]のPFセットのメモリ消費量としてカウントされる。スタック[6]の処理が行われた後、スタック[6]はスレッドからなくなりスタック[5]がTOPSTACKになる。スタック[5]〜[0]でも同様の処理が行われるので、全て、スタック[0]のPFセットのメモリ消費量としてカウントされる。   FIG. 7 shows the allocation state of the memory consumption of each stack when the second group selection algorithm is executed. As shown in FIG. 7, the memory consumption of all stacks of a thread is allocated to the bottom stack [0]. Here, how the memory consumption of the stack [6] is counted will be described. The stack [6] is called by the stack [5], and the stack [5] is called by the stack [4]. The stack [4] is called by the stack [3], and the stack [3] is called by the stack [2]. The stack [2] is called by the stack [1], and the stack [1] is called by the stack [0]. Since there is no caller in the stack [0], as a result, the memory consumption of the stack [6] is counted as the memory consumption of the PF set of the stack [0]. After the processing of stack [6] is performed, stack [6] disappears from the thread and stack [5] becomes TOPSTOP. Since the same processing is performed on the stacks [5] to [0], all are counted as the memory consumption of the PF set of the stack [0].

以上より、全てのスタックのクラスのメモリ消費量を、最初に呼び出しを行ったスタックのクラスに対して設定されたグループに割り当てるので、ソース消費量をスレッド単位で制限できる。   As described above, the memory consumption amount of all stack classes is assigned to the group set for the stack class that is first called, so that the source consumption amount can be limited in units of threads.

<第3グループ選択アルゴリズム>
第3グループ選択アルゴリズムの動作を示すフローチャートを図8に示す。第3グループ選択アルゴリズムは、TOPSTACKでメモリが要求されるたびに、要求されたメモリ消費量を割り当てるグループを選択する。
<Third group selection algorithm>
A flowchart showing the operation of the third group selection algorithm is shown in FIG. The third group selection algorithm selects a group to which the requested memory consumption is allocated every time memory is requested with TOPSTOP.

まず、初期値として、groupIDにGROUPID_PFを代入し(S301)、curStackにTOPSTACKを代入して以下の処理を行う(S302)。   First, as an initial value, GROUPID_PF is substituted for groupID (S301), and TOPSTACK is substituted for curStack (S302).

curGroupIDにcurStackの指すスタックのグループIDを代入する(S303)。   The group ID of the stack pointed to by curStack is substituted for curGroupID (S303).

curGroupIDがGROUPID_PFであって(S304のYES)、groupIDがGROUPID_PFでない場合(S305のNO)、つまり、呼び出し元がPFセットでクラス提供側がSPバンドルセットの象限cの場合は、そのときのgroupIDの値、つまり、クラス提供側のスタックのSPバンドルセットのグループを選択されたグループとして処理を終了する。   If curGroupID is GROUPID_PF (YES in S304) and groupID is not GROUPID_PF (NO in S305), that is, if the caller is the PF set and the class provider is in the quadrant c of the SP bundle set, the value of the groupID at that time That is, the processing is terminated with the group of the SP bundle set of the stack on the class providing side as the selected group.

curGroupIDがGROUPID_PFでない場合(S304のNO)、あるいは、curGroupIDがGROUPID_PFであって(S304のYES)、groupIDがGROUPID_PFである場合(S305のYES)、つまり、象限a,b,dの場合は、groupIDにcurGroupIDの値を代入し(S306)、curStackが指すスタックを一つ下げる(S307)。   If curGroupID is not GROUPID_PF (NO in S304), or if curGroupID is GROUPID_PF (YES in S304) and groupID is GROUPID_PF (YES in S305), that is, if it is quadrant a, b, d, groupID The value of curGroupID is substituted into (S306), and the stack pointed to by curStack is lowered by one (S307).

そして、curStackがNullでなければS303に戻り(S308のNO)、curStackがNullであれば(S308のYES)、そのときにgroupIDの値を選択されたグループとして処理するを終了する。   If curStack is not Null, the process returns to S303 (NO in S308), and if curStack is Null (YES in S308), processing of the groupID value as the selected group is terminated.

システムの基盤となるPFセットが、SPバンドルセットを利用することによってPFセットのための機能を実現することはあり得ない。それ故に、機能を提供するPFセットのメモリ消費量を、機能を利用するSPバンドルセットに対して設定されたグループに割り当てる。つまり、機能提供者であるPF事業者によって生成されたPFセットと、機能利用者であるSP事業者によって生成されたSPバンドルセット間の関係において、PFセットのメモリ消費量は呼び出し元・クラス提供側に関わらず、機能を利用しているSPバンドルセットのメモリ消費量としてカウントする。   The PF set serving as the base of the system cannot realize the function for the PF set by using the SP bundle set. Therefore, the memory consumption of the PF set that provides the function is allocated to the group set for the SP bundle set that uses the function. In other words, in the relationship between the PF set generated by the PF provider as the function provider and the SP bundle set generated by the SP provider as the function user, the memory consumption of the PF set is provided by the caller / class. Regardless of the side, it counts as the memory consumption of the SP bundle set that uses the function.

例えば、SPバンドルセットがPFセットを呼び出す象限bの例としては、、PFセットがHttpServiceを実装したバンドルを提供し、SPバンドルセットがHttpServiceを取得して呼び出すことにより、PFセットの提供するHttpServiceの機能を利用する例が考えられる。   For example, as an example of the quadrant b in which the SP bundle set calls the PF set, the PF set provides a bundle that implements http service, and the SP bundle set obtains and calls the http service, so that the HTTP service provided by the PF set is provided. An example of using the function can be considered.

また、PFセットがSPバンドルセットを呼び出す象限cの例としては、OSGi仕様で定義されるBundleActivator#startの呼び出しがある。呼び出すのはOSGiFW、つまりPFセットであるが、SPバンドルセットがクラス提供した理由は、PFセットが提供する「SPバンドルを対象端末上で起動する機能」を利用する為である。どのような場合においても、象限cは、背景技術で説明した通りコールバック型、つまりクラス提供側であるSPバンドルセットが機能を利用する形となる。   Further, as an example of the quadrant c in which the PF set calls the SP bundle set, there is a call to BundleActivator # start defined in the OSGi specification. The OSGiFW, that is, the PF set is called, but the reason that the SP bundle set provides the class is to use the “function for starting the SP bundle on the target terminal” provided by the PF set. In any case, the quadrant c is a callback type as described in the background art, that is, the SP bundle set on the class providing side uses the function.

なお、象限aや象限d、つまりPFセットがPFセットを呼び出した場合や、SPバンドルセットがSPバンドルセットを呼び出した場合は、機能の提供利用によらず、呼び出したSPバンドルセットのメモリ消費量としてカウントする。   Note that when the quadrant a or quadrant d, that is, when the PF set calls the PF set, or when the SP bundle set calls the SP bundle set, the memory consumption of the called SP bundle set regardless of the provision of functions. Count as.

呼び出し元・クラス提供側のスタックの関係を表すと、図9に示すようになる。この図は、2つのスタックの関係において、上のクラス提供側のスタックのメモリ消費量が、どちらのスタックにおいてカウントされるかを示している。○印から延びる矢印の先がメモリ消費量がカウントされるスタックを示している。同図に示すように、メモリ消費量の割り当て先は、象限cでは上のクラス提供側のスタック、象限a,b,dでは下の呼び出し元のスタックとなっている。   The relationship between the caller / class provider stack is as shown in FIG. This figure shows in which stack the memory consumption of the upper class provider stack is counted in the relationship between the two stacks. The tip of the arrow extending from the circle indicates the stack where the memory consumption is counted. As shown in the figure, the allocation destination of the memory consumption is the stack on the upper class providing side in quadrant c, and the lower caller stack in quadrants a, b, and d.

図10に、第3グループ選択アルゴリズムを実行した際の各スタックのメモリ消費量の割り当て状況を示す。以下、各スタックのメモリ消費量がどのようにカウントされるのかを説明する。   FIG. 10 shows the allocation status of the memory consumption of each stack when the third group selection algorithm is executed. Hereinafter, how the memory consumption of each stack is counted will be described.

まず、PFセットであるスタック[6]のメモリ消費量は、呼び出し元のスタック[5]がSP_BS1なので、呼び出し元のスタック[5]のメモリ消費量としてカウントされる(象限b)。   First, the memory consumption of the stack [6], which is a PF set, is counted as the memory consumption of the caller stack [5] because the caller stack [5] is SP_BS1 (quadrant b).

SP_BS1であるスタック[5]のメモリ消費量は、呼び出し元のスタック[4]がSP_BS2なので、呼び出し元のスタック[4]のメモリ消費量としてカウントされる(象限d)。   The memory consumption of the stack [5], which is SP_BS1, is counted as the memory consumption of the caller stack [4] because the caller stack [4] is SP_BS2 (quadrant d).

スタック[4]のメモリ消費量は、呼び出元のスタック[3]がPFセットなので、クラス提供側のスタック[4]のメモリ消費量としてカウントされる(象限c)。   The memory consumption of the stack [4] is counted as the memory consumption of the stack [4] on the class providing side (quadrant c) because the stack [3] of the caller is the PF set.

よって、スタック[4]〜[6]におけるメモリ消費量は、スタック[4]つまりSP_BS2のメモリ消費量としてカウントされる。   Therefore, the memory consumption in the stacks [4] to [6] is counted as the memory consumption of the stack [4], that is, SP_BS2.

同様に、スタック[3]のメモリ消費量は、呼び出し元のスタック[2]がPFセットなので、呼び出し元のスタック[2]のメモリ消費量としてカウントとされる(象限a)。   Similarly, the memory consumption of the stack [3] is counted as the memory consumption of the caller stack [2] because the caller stack [2] is the PF set (quadrant a).

スタック[2]のメモリ消費量は、呼び出し元のスタック[1]がSP_BS1なので、呼び出し元のスタック[1]のメモリ消費量としてカウントとされる(象限b)。   The memory consumption of the stack [2] is counted as the memory consumption of the call stack [1] because the call stack [1] is SP_BS1 (quadrant b).

スタック[1]のメモリ消費量は、呼び出し元のスタック[0]がPFセットなので、クラス提供側のスタック[1]のメモリ消費量としてカウントされる(象限c)。   The memory consumption of the stack [1] is counted as the memory consumption of the stack [1] on the class providing side (quadrant c) because the stack [0] of the caller is a PF set.

よって、スタック[1]〜[3]におけるメモリ消費量は、スタック[1]つまりSP_BS1のメモリ消費量としてカウントされる。   Therefore, the memory consumption in the stacks [1] to [3] is counted as the memory consumption of the stack [1], that is, SP_BS1.

最後に、スタック[0]のメモリ消費量は、呼び出し元のスタックが存在しないので、スタック[0]つまりPFセットのメモリ消費量としてカウントとされる。   Finally, the memory consumption of the stack [0] is counted as the memory consumption of the stack [0], that is, the PF set because there is no caller stack.

以上より、機能を提供するPFセットのメモリ消費量を、機能を利用するSPバンドルセットに対して設定されたグループに割り当てるので、機能を利用するバンドルセット単位でメモリ消費量を制限できる。   As described above, the memory consumption amount of the PF set that provides the function is assigned to the group set for the SP bundle set that uses the function, so that the memory consumption amount can be limited for each bundle set that uses the function.

<第4グループ選択アルゴリズム>
第3グループ選択アルゴリズムでは、機能の提供・利用の関係について、機能を提供するのはPFセットと機能を利用するのはSPバンドルセットとしてグループを選択した。一方、機能の提供・利用の関係はSPバンドルセット同士にもあるため、第4グループ選択アルゴリズムではSPバンドルセット同士の機能の提供・利用の関係を考慮する。
<4th group selection algorithm>
In the third group selection algorithm, regarding the relationship between the provision and use of functions, a group is selected as a PF set that provides functions and an SP bundle set that uses functions. On the other hand, since the function provision / use relationship also exists between SP bundle sets, the fourth group selection algorithm considers the function provision / use relationship between SP bundle sets.

第4グループ選択アルゴリズムの動作を示すフローチャートを図11に示す。第4グループ選択アルゴリズムは、TOPSTACKでメモリが要求されるたびに、要求されたメモリ消費量を割り当てるグループを選択する。   A flowchart showing the operation of the fourth group selection algorithm is shown in FIG. The fourth group selection algorithm selects a group to which the requested memory consumption is allocated every time memory is requested with TOPSTOP.

なお、第4グループ選択アルゴリズムを用いるにあたり、JavaVM10は、クラスローダオブジェクトのデータ構造にCTF(Class Type Flag:クラスが「機能提供」か「機能利用」を示すフラグ)を設定できるデータ構造を用意し、指定されたクラスローダオブジェクトのデータ構造に指定されたCTFを設定する機能を有する。特に指定のない場合、PFセットのクラスローダオブジェクトのCTFは「機能利用」とする。以下では、CUR_CTFはcurStackのクラスのCTFを表し、last_CTFには、初期値以外では、curStackより上のスタックで、一番curStackに近いSPバンドルセットのスタックに付与されているCTFが代入される。また、groupIDには、初期値以外では、curStackより上のスタックで、一番curStackに近いSPバンドルセットに設定されたグループIDが代入される。   When using the fourth group selection algorithm, the Java VM 10 prepares a data structure that can set CTF (Class Type Flag: a flag indicating whether the class is “provide function” or “use function”) in the data structure of the class loader object. And a function of setting the designated CTF in the data structure of the designated class loader object. Unless otherwise specified, the CTF of the class loader object of the PF set is “use function”. In the following, CUR_CTF represents the CTF of the curStack class, and CTF assigned to the stack of the SP bundle set closest to curStack is substituted for last_CTF, except for the initial value, in the stack above curStack. In addition to groupID, the group ID set in the SP bundle set closest to curStack in the stack above curStack is substituted for groupID.

まず、初期値として、groupIDにGROUPID_PFを代入し(S401)、curStackにTOPSTACKを代入して以下の処理を行う(S402)。   First, as an initial value, GROUPID_PF is substituted for groupID (S401), and TOPSTACK is substituted for curStack (S402).

last_CTFに「機能提供」を代入し(S403)、curGroupIDにcurStackの指すスタックのグループIDを代入する(S404)。   “Provide function” is substituted into last_CTF (S403), and the group ID of the stack pointed to by curStack is substituted into curGroupID (S404).

curGroupIDがGROUPID_PFである場合に(S405のYES)、curGroupIDがgroupIDと異なり(S406のNO)、CUR_CTFが「機能利用」である場合は(S407のYES)、そのときのgroupIDの値を選択されたグループとして処理を終了する。一方、curGroupIDがgroupIDと同じであるか(S406のYES)、CUR_CTFが「機能利用」でない場合は(S407のNO)、S412に進み、1つ下のスタックについて処理を続ける。   When curGroupID is GROUPID_PF (YES in S405), curGroupID is different from groupID (NO in S406), and when CUR_CTF is "use of function" (YES in S407), the groupID value at that time is selected End processing as a group. On the other hand, if curGroupID is the same as groupID (YES in S406) or if CUR_CTF is not “use of function” (NO in S407), the process proceeds to S412 and processing is continued for the next lower stack.

curGroupIDがGROUPID_PFでない場合に(S405のNO)、curGroupIDがgroupIDと異なり(S408のNO)、last_CTFが「機能利用」である場合は(S409のYES)、そのときのgroupIDの値を選択されたグループとして処理を終了する。一方、curGroupIDがgroupIDと同じであるか(S408のYES)、last_CTFが「機能利用」でない場合は(S409のNO)、groupID、last_CTFを更新して(S410,S411)、S412に進み、1つ下のスタックについて処理を続ける。なお、curGroupIDがgroupIDと同じ場合は(S408のYES)、S410でgroupIDを更新する必要がないのでS411に進む。   If curGroupID is not GROUPID_PF (NO in S405), curGroupID is different from groupID (NO in S408), and if last_CTF is "use of function" (YES in S409), the groupID value at that time is selected To finish the process. On the other hand, if curGroupID is the same as groupID (YES in S408) or if last_CTF is not “use of function” (NO in S409), the groupID and last_CTF are updated (S410, S411), and the process proceeds to S412. Continue processing for the lower stack. If curGroupID is the same as groupID (YES in S408), it is not necessary to update the groupID in S410, and the process proceeds to S411.

1つ下のスタックについて処理を続ける場合、curStackが指すスタックを1つ下げて(S412)、curStackがNullでなければS404に戻り(S413のNO)、curStackがNullであれば(S413のYES)、そのときのgroupIDの値を選択されたグループとして処理を終了する。   When processing is continued for the next lower stack, the stack pointed to by curStack is lowered by one (S412). If curStack is not Null, the process returns to S404 (NO in S413), and if curStack is Null (YES in S413). Then, the process ends with the groupID value at that time as the selected group.

各象限の呼び出し関係とメモリ消費量のカウント先を示すと、図12に示すようになる。第3グループ選択アルゴリズムとは、象限d、つまり、SPバンドルセットがSPバンドルセットを呼び出した際のメモリ消費量の割り当て先が異なる。第4グループ選択アルゴリズムでは、呼び出し元・クラス提供側のスタックの関係が象限dの場合、クラス提供側のスタックのCTFの値によってメモリ消費量の割り当て先が変わる。具体的には、クラス提供側のスタックのCTFが「機能利用」である場合(象限dの左側)、クラス提供側のスタックにメモリ消費量が割り当てられ、クラス提供側のスタックのCTFが「機能提供」である場合(象限dの右側)、呼び出し元のスタックにメモリ消費量が割り当てられる。   FIG. 12 shows the calling relationship of each quadrant and the memory consumption count destination. It differs from the third group selection algorithm in quadrant d, that is, the allocation destination of memory consumption when the SP bundle set calls the SP bundle set. In the fourth group selection algorithm, when the caller / class provider stack relationship is in quadrant d, the allocation destination of the memory consumption varies depending on the CTF value of the class provider stack. Specifically, when the CTF of the stack on the class providing side is “use of function” (left side of quadrant d), the memory consumption is allocated to the stack on the class providing side, and the CTF of the stack on the class providing side is “function”. If it is “provide” (right side of quadrant d), the memory consumption is allocated to the stack of the caller.

図13に、第4グループ選択アルゴリズムを実行した際の各スタックのメモリ消費量の割り当て状況を示す。図13(a)は、スタック[5]が機能利用クラスであった場合の割り当て状況であり、図13(b)は、スタック[5]が機能提供クラスであった場合の割り当て状況である。   FIG. 13 shows the allocation status of the memory consumption of each stack when the fourth group selection algorithm is executed. FIG. 13A shows an assignment situation when stack [5] is a function use class, and FIG. 13B shows an assignment situation when stack [5] is a function provision class.

まず、スタック[5]が機能利用クラスである図13(a)においてどのようにカウントされるかを説明する。   First, it will be described how stack [5] is counted in FIG. 13A, which is a function use class.

PFセットであるスタック[6]のメモリ消費量は、呼び出し元のスタック[5]がSP_BS1なので、呼び出し元のスタック[5]のメモリ消費量としてカウントされる(象限b)。   The memory consumption of the stack [6], which is a PF set, is counted as the memory consumption of the caller stack [5] because the caller stack [5] is SP_BS1 (quadrant b).

SP_BS1であるスタック[5]のメモリ消費量は、呼び出し元のスタック[4]がSP_BS2であり、機能利用クラスであるので、クラス提供側のスタック[5]のメモリ消費量としてカウントされる(象限d)。   The memory consumption of the stack [5] which is SP_BS1 is counted as the memory consumption of the stack [5] on the class providing side because the caller stack [4] is SP_BS2 and is a function use class (quadrant). d).

なお、スタック[4]〜スタック[0]については第3グループ選択アルゴリズムで説明した例と同様である。   The stack [4] to stack [0] are the same as the example described in the third group selection algorithm.

続いて、スタック[5]が機能提供クラスである図13(b)においてどのようにカウントされるかを説明する。   Next, how stack [5] is counted in FIG. 13B, which is a function providing class, will be described.

PFセットであるスタック[6]のメモリ消費量は、呼び出し元のスタック[5]がSP_BS1なので、呼び出し元のスタック[5]のメモリ消費量としてカウントされる(象限b)。   The memory consumption of the stack [6], which is a PF set, is counted as the memory consumption of the caller stack [5] because the caller stack [5] is SP_BS1 (quadrant b).

SP_BS1であるスタック[5]のメモリ消費量は、呼び出し元のスタック[4]がSP_BS2であり、機能提供クラスであるので、呼び出し元のスタック[4]のメモリ消費量としてカウントされる(象限d)。   The memory consumption of the stack [5], which is SP_BS1, is counted as the memory consumption of the stack [4] of the caller since the caller stack [4] is SP_BS2 and is a function providing class (quadrant d ).

なお、スタック[4]〜スタック[0]については第3グループ選択アルゴリズムで説明した例と同様である。   The stack [4] to stack [0] are the same as the example described in the third group selection algorithm.

以上より、スタックの状況が象限dの場合に、機能を提供するSPバンドルセットのメモリ消費量を、機能を利用するSPバンドルセットのメモリ消費量としてカウントするので、第3グループ選択アルゴリズムの効果に加えて、SPバンドルセット同士の呼び出しにおいても、機能の提供・利用によってリソース消費量のカウント先を変更できる。   As described above, when the stack status is in quadrant d, the memory consumption of the SP bundle set that provides the function is counted as the memory consumption of the SP bundle set that uses the function. In addition, even when calling between SP bundle sets, the resource consumption count destination can be changed by providing and using the function.

なお、上記の第4グループ選択アルゴリズムを実現するために、リソース管理バンドル12aおよびJavaVM10に対して以下の機能を追加する。   In addition, in order to implement | achieve said 4th group selection algorithm, the following functions are added with respect to the resource management bundle 12a and JavaVM10.

リソース管理バンドル12aは、SPバンドル131のクラスが機能の提供・利用どちらを行うクラスかの情報をサーバ3等から入手し、JavaVM10に対して、SPバンドル131のクラス毎にCTFを設定する機能を有する。JavaVM10は、クラスローダオブジェクトにCTFを設定できるデータ構造を用意し、クラスローダオブジェクトに指定されたCTFを設定する機能を有する。   The resource management bundle 12a has a function of acquiring information on whether the class of the SP bundle 131 provides or uses a function from the server 3 or the like and setting a CTF for each class of the SP bundle 131 to the Java VM 10. Have. The Java VM 10 prepares a data structure that can set a CTF in a class loader object, and has a function of setting a CTF specified in the class loader object.

以下、オブジェクトにCTFを設定する処理について説明する。   Hereinafter, processing for setting a CTF for an object will be described.

リソース管理バンドル12aは、バンドルセット情報とバンドルセットメモリ量に加えて、バンドルセット情報に含まれるSPバンドル131のクラスにセットするCTFを取得しておく。   In addition to the bundle set information and the bundle set memory amount, the resource management bundle 12a acquires a CTF to be set in the class of the SP bundle 131 included in the bundle set information.

SPバンドル131がOSGiFW11にインストールされ、リソース管理バンドル12aがOSGiFW11からResolvedイベントを受信すると、インストールされたSPバンドル131の属するSPバンドルセット13に関連付けるグループIDをJavaVM10から取得する。続いて、インストールされたSPバンドル131のクラスローダオブジェクトを取得し、取得したクラスローダオブジェクトとグループIDをJavaVM10に通知し、さらに、取得したクラスローダオブジェクトと該当するCTFをJavaVM10に通知する。JavaVM10は、通知されたクラスローダオブジェクトにグループID、CTFを設定する。   When the SP bundle 131 is installed in the OSGiFW 11 and the resource management bundle 12a receives the Resolved event from the OSGiFW 11, the group ID associated with the SP bundle set 13 to which the installed SP bundle 131 belongs is acquired from the Java VM 10. Subsequently, the class loader object of the installed SP bundle 131 is acquired, the acquired class loader object and the group ID are notified to the Java VM 10, and further, the acquired class loader object and the corresponding CTF are notified to the Java VM 10. The Java VM 10 sets the group ID and CTF for the notified class loader object.

以上説明したように、本実施の形態によれば、メモリ消費量をカウントするグループをグループ選択アルゴリズムに基づいて決定することにより、グループ選択アルゴリズムを変更することで、メモリ消費量を制限する単位を変更できる。具体的には、第1グループ選択アルゴリズムを用いた場合は、実装クラスのセット単位でメモリ消費量を制限でき、第2グループ選択アルゴリズムを用いた場合は、スレッド単位でメモリ消費量を制限できる。また、第3,4グループ選択アルゴリズムを用いた場合は、機能を利用するバンドルセット単位でメモリ消費量を制限できる。その結果、複数のSP事業者が1つのシステムを共有して同時にサービスを提供するような場合において、協調して動作する種々のSPバンドルのメモリ消費量を、どのグループ(SP事業者)でカウントするかを柔軟に決定できる。   As described above, according to the present embodiment, the unit for limiting the memory consumption is determined by changing the group selection algorithm by determining the group for counting the memory consumption based on the group selection algorithm. Can change. Specifically, when the first group selection algorithm is used, the memory consumption can be limited in units of mounting classes, and when the second group selection algorithm is used, the memory consumption can be limited in units of threads. Further, when the third and fourth group selection algorithms are used, the memory consumption can be limited in units of bundle sets that use functions. As a result, when multiple SP providers share a system and provide services at the same time, which group (SP provider) counts the memory consumption of various SP bundles that operate in a coordinated manner. You can decide flexibly.

また、グループ選択アルゴリズムは、スタックからポインタ参照で辿れる情報のみを利用しているので、メモリ割り当て時の速度低下を低減できる。   Further, since the group selection algorithm uses only information that can be traced from the stack by pointer reference, it is possible to reduce the speed reduction during memory allocation.

〔メモリ消費量の計測について〕
次に、本実施の形態におけるメモリ管理装置1のメモリ消費量の計測方法について説明する。JavaVM10は、指定されたグループに割り当てられたメモリ消費量の合計を返す機能を有する。JavaVM10は、グループIDが指定されてそのグループのメモリ消費量の問い合わせがあると、まず、GCを行う。あるいは、メモリ消費量の問い合わせの前に、問い合わせるプログラム側でSystem.gc()などを用いてGCを行うものでもよい。ここでは、GCは、グループID毎に行うか、ヒープ領域全体で行うかは問わない。
[Measurement of memory consumption]
Next, a memory consumption measuring method of the memory management device 1 in the present embodiment will be described. The Java VM 10 has a function of returning the total memory consumption allocated to the specified group. When the group ID is specified and the memory consumption of the group is inquired, the Java VM 10 first performs GC. Alternatively, before inquiring about the memory consumption, the inquiring program side may request System. GC may be performed using gc () or the like. Here, it does not matter whether GC is performed for each group ID or the entire heap area.

GC後に、指定されたグループIDを持つGC対象とならなかったオブジェクトのサイズを合計し、その合計値を指定されたグループのメモリ消費量として返却する。   After GC, the sizes of objects that are not GC targets with the specified group ID are summed, and the total value is returned as the memory consumption of the specified group.

以上より、グループID単位でメモリ消費量を計測できる。   As described above, the memory consumption can be measured in units of group IDs.

〔グループの削除について〕
次に、グループの削除について説明する。JavaVM10は、指定されたグループIDに該当するグループを削除する機能を有する。
[About group deletion]
Next, group deletion will be described. The Java VM 10 has a function of deleting a group corresponding to the specified group ID.

JavaVM10は、削除対象のグループIDが指定されると、そのグループIDが付与されているオブジェクトに対する参照がなくなった時点で指定されたグループIDを削除する。これにより、グループの削除が可能となる。   When the deletion target group ID is specified, the Java VM 10 deletes the specified group ID when there is no longer a reference to the object to which the group ID is assigned. As a result, the group can be deleted.

〔実施例〕
以下、本実施の形態におけるいくつかの実施例を説明する。
〔Example〕
Hereinafter, some examples in the present embodiment will be described.

<PFセットからSPバンドルセットへの呼び出しにおける実施例>
第3,4グループ選択アルゴリズムにおいて、SPバンドルセット1(以下、SP1)が、SPバンドルセット2(以下、SP2)を呼び出す例を考える。
<Example in Calling from PF Set to SP Bundle Set>
Consider an example in which the SP bundle set 1 (hereinafter referred to as SP1) calls the SP bundle set 2 (hereinafter referred to as SP2) in the third and fourth group selection algorithms.

SP2の内部でPFセットを呼び出すと、図14に示すように、SPバンドルがPFセットを呼び出した際、PFセットの処理で再度SPバンドルが呼び出される場合がある。このようなスタック構造になるPFセットのクラスには、例えばAccessController.doPrivileged()などがある。このようなクラスには、CTFを「機能提供」に設定し、第4グループ選択アルゴリズムを適用する。   When the PF set is called inside SP2, as shown in FIG. 14, when the SP bundle calls the PF set, the SP bundle may be called again by the processing of the PF set. The class of the PF set having such a stack structure includes, for example, AccessController. doPrivileged () and the like. For such a class, the CTF is set to “provide function” and the fourth group selection algorithm is applied.

以上より、スタック[3]からスタック[4]への呼び出しは、第4グループ選択アルゴリズムにおいてはスタック[3]のSP2のメモリ消費量とカウントされることになる。この例において、SP1がSP2の機能を利用している場合には、スタック[2]〜スタック[4]の呼び出しは、SP1がSP2の機能を利用するために行われていることになる。つまり、スタック[2]〜[4]に割り当てられたメモリは、機能を利用しているSP1のメモリ消費量としてカウントされることが望ましく、それを実現することができる。   As described above, the call from the stack [3] to the stack [4] is counted as the SP2 memory consumption of the stack [3] in the fourth group selection algorithm. In this example, when SP1 uses the function of SP2, the stack [2] to stack [4] are called in order for SP1 to use the function of SP2. That is, the memory allocated to the stacks [2] to [4] is desirably counted as the memory consumption of the SP1 that uses the function, and this can be realized.

<PFセットを詳細に分割する実施例>
ブートストラップクラスローダからロードされるクラスを、JavaVM10のクラスとみなし、システムクラスローダからロードされるクラスを、OSGiFW11のクラスとみなす。それぞれのクラスローダオブジェクトの構造体に別のグループIDを設定し、第1グループ選択アルゴリズムを用いる。
<Example in which a PF set is divided in detail>
A class loaded from the bootstrap class loader is regarded as a Java VM 10 class, and a class loaded from the system class loader is regarded as an OSGiFW 11 class. A different group ID is set for each class loader object structure, and the first group selection algorithm is used.

以上より、同一クラスローダからロードされるクラスごとにメモリ消費量を制限できる。特に、第1グループ選択アルゴリズムではPFセット14は1つとしたが、PFセット14をJavaVM10とOSGiFW11とに分割できる。   As described above, the memory consumption can be limited for each class loaded from the same class loader. In particular, in the first group selection algorithm, the number of PF sets 14 is one, but the PF set 14 can be divided into Java VM 10 and OSGiFW 11.

<スレッドとグループIDとを結び付ける実施例>
スレッドとグループIDとを結び付ける場合、JavaVM10に、スレッドに対してグループIDを設定することができるデータの構造体を追加し、図15に示す第5グループ選択アルゴリズムを用いる。
<Example in which a thread and a group ID are linked>
When linking a thread and a group ID, a data structure capable of setting a group ID for the thread is added to the Java VM 10 and the fifth group selection algorithm shown in FIG. 15 is used.

第5グループ選択アルゴリズムは、スレッドに設定されたグループIDを選択するようにしている(S501)。スレッドが立てられる際、スレッドを立てるクラスのクラスローダオブジェクトに設定されたグループIDを、立てるスレッドの構造体に設定する。   The fifth group selection algorithm selects the group ID set for the thread (S501). When a thread is set up, the group ID set in the class loader object of the class that sets up the thread is set in the structure of the set up thread.

以上より、基本的には、第2グループ選択アルゴリズムを用いた場合と同一の効果が得られるが、スタックを下に辿る動作を不要とするので、第2グループ選択アルゴリズムを用いた場合よりも高速にグループIDを決定できる。   As described above, basically, the same effect as that obtained when the second group selection algorithm is used can be obtained. However, since the operation of tracing down the stack is unnecessary, it is faster than the case where the second group selection algorithm is used. The group ID can be determined.

<GC複数方式の実施例>
GCは、グループID毎に行う方式とヒープ領域全体で行う方式とが考えられる。
<Example of GC multiple system>
The GC is considered to be performed for each group ID and for the entire heap area.

グループ毎に行う方式は、ヒープ領域全体で行う方式と比較して、あるグループIDで頻繁にGCが起こる場合でも、他のグループIDは影響を受けることなく動作することができる。   Compared with the method performed for the entire heap area, the method performed for each group can operate without being influenced by other group IDs even when GC frequently occurs in a certain group ID.

一方、ヒープ領域全体で行う方式は、グループID毎で行う方式と比較して、以下の利点がある。異なるグループIDで頻繁にGCが起こるような状況においては、参照されているオブジェクトをルートから探索する動作が頻繁に起こってしまいオーバーヘッドになる。しかし、ヒープ領域全体でGCを行う場合には、一度に全てのオブジェクトを探索するためこのような、オーバーヘッドがなくなるという利点がある。   On the other hand, the method performed for the entire heap area has the following advantages compared to the method performed for each group ID. In a situation where GC frequently occurs with different group IDs, an operation of searching for a referenced object from the root frequently occurs, resulting in an overhead. However, when GC is performed on the entire heap area, all the objects are searched at once, so that there is an advantage that such overhead is eliminated.

<複数の制限値の実施例>
これまでは、グループにはメモリ使用量の制限値を1つだけ設定していたが、本実施例では、グループにメモリ使用量の制限値を2つ設定する。制限値のひとつをSoftLimit、もうひとつをHardLimitとする。ここでSoftLimit<HardLimitである。また、JavaVM10は、グループID毎に、GC終了時にGC対象とならなかったオブジェクトに割り当てられたメモリ消費量の合計であるキャッシュメモリ消費量積算値を保持する。
<Example of multiple limit values>
Until now, only one limit value for memory usage has been set for a group, but in this embodiment, two limit values for memory usage are set for a group. One of the limit values is SoftLimit, and the other is HardLimit. Here, SoftLimit <HardLimit. Further, the Java VM 10 holds, for each group ID, a cache memory consumption integrated value that is a total of memory consumptions allocated to objects that are not GC targets at the end of GC.

メモリを割り当てる際、選択されたグループのキャッシュメモリ消費量積算値がSoftLimitを超過していた場合、メモリの割り当てが失敗したとして、GCを実行せずにOOMエラーを発生させる。   When the cache memory consumption integrated value of the selected group exceeds the SoftLimit when the memory is allocated, it is determined that the memory allocation has failed and an OOM error is generated without executing the GC.

選択されたグループのキャッシュメモリ消費量積算値がSoftLimitを超過していない場合は、HardLimitをメモリ消費量の制限値として、制限値が1つの場合と同様の処理を行う。具体的には、選択されたグループのメモリ消費量積算値に生成されるオブジェクトのサイズを加算した値が、HardLimit以下の場合は、メモリの割り当ては成功とし、選択されたグループのメモリ消費量積算値に生成されるオブジェクトのサイズを加算した値が、HardLimitより大きい場合は、GCを実行し、選択されたグループの新たなメモリ消費量積算値に生成されるオブジェクトのサイズを加算してメモリを割り当てるか否か判定する。GCを実行してもメモリ消費量積算値にオブジェクトのサイズを加算した値がHardLimitを超える場合は、OOMエラーを発生させる。   If the cache memory consumption integrated value of the selected group does not exceed SoftLimit, the same processing as in the case where the limit value is one is performed with HardLimit as the memory consumption limit value. Specifically, when the value obtained by adding the size of the generated object to the accumulated memory consumption value of the selected group is equal to or less than HardLimit, the memory allocation is successful, and the accumulated memory consumption of the selected group is determined. If the value obtained by adding the size of the generated object to the value is larger than HardLimit, GC is executed, and the memory size is increased by adding the size of the generated object to the new memory consumption integrated value of the selected group. Judge whether to allocate. If the value obtained by adding the object size to the memory consumption integrated value exceeds HardLimit even after GC is executed, an OOM error is generated.

特定のグループのSPバンドルが短時間の間にメモリ消費量の制限値までリソースを消費し、GCによって解放されるような実装をしている場合、メモリ消費量の制限値が1つであればGCが頻発し、結果として、JavaVM全体の処理速度が低下する可能性がある。本実施例を用いることで、SoftLimit<該当グループIDのキャッシュメモリ消費量積算量であった場合、GCをする前にOOMエラーが発生するので、GCの頻発を抑えることが可能となり、結果として、処理速度の低下を抑制できる。   If the SP bundle of a specific group consumes resources up to the memory consumption limit value in a short time and is released by the GC, if the memory consumption limit value is one GC frequently occurs, and as a result, the processing speed of the entire JavaVM may be reduced. By using this example, if SoftLimit <the cache memory consumption integrated amount of the corresponding group ID, an OOM error occurs before GC, so it is possible to suppress frequent occurrence of GC. Reduction in processing speed can be suppressed.

<PFセットに制限値を設定する実施例>
PFセット14のリソース消費は、JavaVM10の起動から始まる。よって、JavaVM10が起動後、リソース管理バンドル12aが起動してPFセット14のメモリ消費量の制限値を設定した後では、PFセット14に対して制限したい制限値を超過している可能性がある。
<Example in which limit value is set in PF set>
The resource consumption of the PF set 14 starts from the activation of the Java VM 10. Therefore, after the Java VM 10 is started, after the resource management bundle 12a is started and the memory consumption limit value of the PF set 14 is set, there is a possibility that the limit value to be restricted for the PF set 14 is exceeded. .

そこで、JavaVM10起動時に起動オプションとしてPFセット14に対する制限値を設定する。   Therefore, a limit value for the PF set 14 is set as a startup option when the Java VM 10 is started.

以上より、PFセット14に対して制限値を確実に設定することができ、PFセット14の制限値超過を防ぐことが可能となる。   As described above, it is possible to reliably set the limit value for the PF set 14 and prevent the limit value of the PF set 14 from being exceeded.

1…メモリ管理装置
10…JavaVM(Java仮想マシン)
11…OSGiFW
12…オーナーバンドル
12a…リソース管理バンドル
13…SPバンドルセット
131…SPバンドル
14…PFセット
DESCRIPTION OF SYMBOLS 1 ... Memory management apparatus 10 ... JavaVM (Java virtual machine)
11 ... OSGiFW
12 ... Owner bundle 12a ... Resource management bundle 13 ... SP bundle set 131 ... SP bundle 14 ... PF set

Claims (12)

ソフトウェアプラットフォーム上で動作するバンドルが利用するメモリを管理するメモリ管理装置であって、
メモリの管理単位でグループを作成し、グループ毎に利用できるメモリ量の制限値を設定し、前記バンドルをインストールする際に、当該バンドルのクラスローダオブジェクトに前記グループを設定する設定手段と、
前記バンドルあるいは前記ソフトウェアプラットフォームのクラスローダオブジェクトがメモリを要求したときに、メモリを要求した前記バンドルあるいは前記ソフトウェアプラットフォームのクラスローダオブジェクトに設定されたグループを要求メモリ量のカウント先として選択する選択手段と、
前記選択手段が選択したグループにすでに割り当てられたメモリの合計値であるメモリ消費量積算値に前記要求メモリ量を加えた予想積算値と当該グループに設定された制限値とを比較し、前記予想積算値が前記制限値以下の場合は、ヒープ領域から前記要求メモリ量のメモリを割り当てるとともに、当該グループの前記メモリ消費量積算値に前記要求メモリ量を加えて前記メモリ消費量積算値を更新し、前記予想積算値が前記制限値を超えた場合はエラーを発生する割当手段と、
を有することを特徴とするメモリ管理装置。
A memory management device for managing memory used by a bundle operating on a software platform,
A setting unit for creating a group in a memory management unit, setting a limit value of a memory amount that can be used for each group, and setting the group in a class loader object of the bundle when installing the bundle ;
When the class loader object of the bundle or the software platform requests a memory, and a selection means for selecting the bundle or group set to the class loader object of the software platform which requested the memory as the count which the request amount of memory ,
A predicted integrated value obtained by adding the required memory amount to a memory consumption integrated value that is a total value of memory already allocated to the group selected by the selection unit and a limit value set for the group, and When the integrated value is less than or equal to the limit value, the memory of the required memory amount is allocated from the heap area, and the required memory amount is added to the memory consumption integrated value of the group to update the memory consumption integrated value. Assigning means for generating an error when the predicted integrated value exceeds the limit value;
A memory management device comprising:
ソフトウェアプラットフォーム上で動作するバンドルが利用するメモリを管理するメモリ管理装置であって、
メモリの管理単位でグループを作成し、グループ毎に利用できるメモリ量の制限値を設定し、前記バンドルをインストールする際に、当該バンドルのクラスローダオブジェクトに前記グループを設定する設定手段と、
前記バンドルあるいは前記ソフトウェアプラットフォームのクラスローダオブジェクトがメモリを要求したときに、メモリを要求した前記バンドルあるいは前記ソフトウェアプラットフォームの呼び出し元を辿り、最初の呼び出し元となるバンドルあるいは前記ソフトウェアプラットフォームが属するグループを要求メモリ量のカウント先として選択する選択手段と、
前記選択手段が選択したグループにすでに割り当てられたメモリの合計値であるメモリ消費量積算値に前記要求メモリ量を加えた予想積算値と当該グループに設定された制限値とを比較し、前記予想積算値が前記制限値以下の場合は、ヒープ領域から前記要求メモリ量のメモリを割り当てるとともに、当該グループの前記メモリ消費量積算値に前記要求メモリ量を加えて前記メモリ消費量積算値を更新し、前記予想積算値が前記制限値を超えた場合はエラーを発生する割当手段と、
を有することを特徴とするメモリ管理装置。
A memory management device for managing memory used by a bundle operating on a software platform,
A setting unit for creating a group in a memory management unit, setting a limit value of a memory amount that can be used for each group, and setting the group in a class loader object of the bundle when installing the bundle ;
When the class loader object of the bundle or the software platform requests a memory, the caller of the bundle or the software platform that requested the memory is traced, and the bundle that is the first caller or the group to which the software platform belongs is requested. A selection means for selecting as a memory amount counting destination;
A predicted integrated value obtained by adding the required memory amount to a memory consumption integrated value that is a total value of memory already allocated to the group selected by the selection unit and a limit value set for the group, and When the integrated value is less than or equal to the limit value, the memory of the required memory amount is allocated from the heap area, and the required memory amount is added to the memory consumption integrated value of the group to update the memory consumption integrated value. Assigning means for generating an error when the predicted integrated value exceeds the limit value;
A memory management device comprising:
ソフトウェアプラットフォーム上で動作するバンドルが利用するメモリを管理するメモリ管理装置であって、
メモリの管理単位でグループを作成し、グループ毎に利用できるメモリ量の制限値を設定し、前記バンドルをインストールする際に、当該バンドルのクラスローダオブジェクトに前記グループを設定する設定手段と、
前記バンドルあるいは前記ソフトウェアプラットフォームのクラスローダオブジェクトがメモリを要求したときに、メモリを要求した前記バンドルあるいは前記ソフトウェアプラットフォームの呼び出し元を辿り、前記ソフトウェアプラットフォームに呼び出されたバンドルが属するグループを要求メモリ量のカウント先として選択する選択手段と、
前記選択手段が選択したグループにすでに割り当てられたメモリの合計値であるメモリ消費量積算値に前記要求メモリ量を加えた予想積算値と当該グループに設定された制限値とを比較し、前記予想積算値が前記制限値以下の場合は、ヒープ領域から前記要求メモリ量のメモリを割り当てるとともに、当該グループの前記メモリ消費量積算値に前記要求メモリ量を加えて前記メモリ消費量積算値を更新し、前記予想積算値が前記制限値を超えた場合はエラーを発生する割当手段と、
を有することを特徴とするメモリ管理装置。
A memory management device for managing memory used by a bundle operating on a software platform,
A setting unit for creating a group in a memory management unit, setting a limit value of a memory amount that can be used for each group, and setting the group in a class loader object of the bundle when installing the bundle ;
When the class loader object of the bundle or the software platform requests the memory, the call source of the bundle or the software platform that requested the memory is traced, and the group to which the bundle called by the software platform belongs is determined as the required memory amount. A selection means for selecting as a count destination;
A predicted integrated value obtained by adding the required memory amount to a memory consumption integrated value that is a total value of memory already allocated to the group selected by the selection unit and a limit value set for the group, and When the integrated value is less than or equal to the limit value, the memory of the required memory amount is allocated from the heap area, and the required memory amount is added to the memory consumption integrated value of the group to update the memory consumption integrated value. Assigning means for generating an error when the predicted integrated value exceeds the limit value;
A memory management device comprising:
ソフトウェアプラットフォーム上で動作するバンドルが利用するメモリを管理するメモリ管理装置であって、
メモリの管理単位でグループを作成し、グループ毎に利用できるメモリ量の制限値を設定し、前記バンドルをインストールする際に、当該バンドルのクラスローダオブジェクトに前記グループを設定する設定手段と、
前記バンドルに機能提供フラグあるいは機能利用フラグを設定する機能設定手段と、
前記バンドルあるいは前記ソフトウェアプラットフォームのクラスローダオブジェクトがメモリを要求したときに、メモリを要求した前記バンドルあるいは前記ソフトウェアプラットフォームの呼び出し元を辿り、前記ソフトウェアプラットフォームに呼び出されたバンドルが属するグループ、又は、機能利用フラグが設定されたバンドルが属するグループを要求メモリ量のカウント先として選択する選択手段と、
前記選択手段が選択したグループにすでに割り当てられたメモリの合計値であるメモリ消費量積算値に前記要求メモリ量を加えた予想積算値と当該グループに設定された制限値とを比較し、前記予想積算値が前記制限値以下の場合は、ヒープ領域から前記要求メモリ量のメモリを割り当てるとともに、当該グループの前記メモリ消費量積算値に前記要求メモリ量を加えて前記メモリ消費量積算値を更新し、前記予想積算値が前記制限値を超えた場合はエラーを発生する割当手段と、
を有することを特徴とするメモリ管理装置。
A memory management device for managing memory used by a bundle operating on a software platform,
A setting unit for creating a group in a memory management unit, setting a limit value of a memory amount that can be used for each group, and setting the group in a class loader object of the bundle when installing the bundle ;
Function setting means for setting a function provision flag or a function use flag in the bundle;
When the class loader object of the bundle or the software platform requests a memory, the caller of the bundle or the software platform that requested the memory is traced, and the group to which the bundle called by the software platform belongs, or function use A selection means for selecting a group to which the bundle with the flag set belongs as a count destination of the requested memory amount;
A predicted integrated value obtained by adding the required memory amount to a memory consumption integrated value that is a total value of memory already allocated to the group selected by the selection unit and a limit value set for the group, and When the integrated value is less than or equal to the limit value, the memory of the required memory amount is allocated from the heap area, and the required memory amount is added to the memory consumption integrated value of the group to update the memory consumption integrated value. Assigning means for generating an error when the predicted integrated value exceeds the limit value;
A memory management device comprising:
ソフトウェアプラットフォーム上で動作するバンドルが利用するメモリを管理するメモリ管理装置であって、A memory management device for managing memory used by a bundle operating on a software platform,
メモリの管理単位でグループを作成し、グループ毎に利用できるメモリ量の制限値を設定し、前記バンドルをインストールする際に、当該バンドルのクラスローダオブジェクトに前記グループを設定する設定手段と、A setting unit for creating a group in a memory management unit, setting a limit value of a memory amount that can be used for each group, and setting the group in a class loader object of the bundle when installing the bundle;
前記バンドルあるいは前記ソフトウェアプラットフォームによりスレッドが立てられるときに、当該スレッドを立てる前記バンドルあるいは前記ソフトウェアプラットフォームのクラスローダオブジェクトに設定されたグループを当該スレッドのグループとして設定するスレッド設定手段と、Thread setting means for setting, as a group of the thread, a group set in the bundle or the software platform class loader object when the thread is set up by the bundle or the software platform;
前記バンドルあるいは前記ソフトウェアプラットフォームのクラスローダオブジェクトがメモリを要求したときに、メモリを要求した前記バンドルあるいは前記ソフトウェアプラットフォームが属するスレッドに設定されたグループを要求メモリ量のカウント先として選択する選択手段と、When the class loader object of the bundle or the software platform requests a memory, a selection unit that selects a group set in a thread to which the bundle or the software platform that requested the memory belongs as a count destination of the requested memory amount;
前記選択手段が選択したグループにすでに割り当てられたメモリの合計値であるメモリ消費量積算値に前記要求メモリ量を加えた予想積算値と当該グループに設定された制限値とを比較し、前記予想積算値が前記制限値以下の場合は、ヒープ領域から前記要求メモリ量のメモリを割り当てるとともに、当該グループの前記メモリ消費量積算値に前記要求メモリ量を加えて前記メモリ消費量積算値を更新し、前記予想積算値が前記制限値を超えた場合はエラーを発生する割当手段と、A predicted integrated value obtained by adding the required memory amount to a memory consumption integrated value that is a total value of memory already allocated to the group selected by the selection unit and a limit value set for the group, and When the integrated value is less than or equal to the limit value, the memory of the required memory amount is allocated from the heap area, and the required memory amount is added to the memory consumption integrated value of the group to update the memory consumption integrated value. Assigning means for generating an error when the predicted integrated value exceeds the limit value;
を有することを特徴とするメモリ管理装置。A memory management device comprising:
ソフトウェアプラットフォーム上で動作するバンドルが利用するメモリを管理するメモリ管理方法であって、
コンピュータによる、
メモリの管理単位でグループを作成し、グループ毎に利用できるメモリ量の制限値を設定するステップと、
前記バンドルをインストールする際に、当該バンドルのクラスローダオブジェクトに前記グループを設定するステップと、
前記バンドルあるいは前記ソフトウェアプラットフォームのクラスローダオブジェクトがメモリを要求したときに、メモリを要求した前記バンドルあるいは前記ソフトウェアプラットフォームのクラスローダオブジェクトに設定されたグループを要求メモリ量のカウント先として選択するステップと、
前記選択するステップで選択したグループにすでに割り当てられたメモリの合計値であるメモリ消費量積算値に前記要求メモリ量を加えた予想積算値と当該グループに設定された制限値とを比較するステップと、
前記予想積算値が前記制限値以下の場合は、ヒープ領域から前記要求メモリ量のメモリを割り当てるとともに、当該グループの前記メモリ消費量積算値に前記要求メモリ量を加えて前記メモリ消費量積算値を更新するステップと、
前記予想積算値が前記制限値を超えた場合は、エラーを発生するステップと、
を有することを特徴とするメモリ管理方法。
A memory management method for managing memory used by a bundle operating on a software platform,
By computer,
Creating a group in the memory management unit and setting a limit value for the amount of memory available for each group;
When installing the bundle, setting the group on the class loader object of the bundle;
When the bundle or the software platform class loader object requests memory, the group set in the bundle or the software platform class loader object that requested the memory is selected as a count destination of the requested memory amount; and
Comparing a predicted integrated value obtained by adding the requested memory amount to a memory consumption integrated value that is a total value of memory already allocated to the group selected in the selecting step and a limit value set for the group; ,
When the predicted integrated value is less than or equal to the limit value, the memory of the required memory amount is allocated from the heap area, and the memory consumption integrated value is calculated by adding the required memory amount to the memory consumption integrated value of the group. A step to update,
If the expected integrated value exceeds the limit value, generating an error;
A memory management method.
ソフトウェアプラットフォーム上で動作するバンドルが利用するメモリを管理するメモリ管理方法であって、
コンピュータによる、
メモリの管理単位でグループを作成し、グループ毎に利用できるメモリ量の制限値を設定するステップと、
前記バンドルをインストールする際に、当該バンドルのクラスローダオブジェクトに前記グループを設定するステップと、
前記バンドルあるいは前記ソフトウェアプラットフォームのクラスローダオブジェクトがメモリを要求したときに、メモリを要求した前記バンドルあるいは前記ソフトウェアプラットフォームの呼び出し元を辿り、最初の呼び出し元となるバンドルあるいは前記ソフトウェアプラットフォームが属するグループを要求メモリ量のカウント先として選択するステップと、
前記選択するステップで選択したグループにすでに割り当てられたメモリの合計値であるメモリ消費量積算値に前記要求メモリ量を加えた予想積算値と当該グループに設定された制限値とを比較するステップと、
前記予想積算値が前記制限値以下の場合は、ヒープ領域から前記要求メモリ量のメモリを割り当てるとともに、当該グループの前記メモリ消費量積算値に前記要求メモリ量を加えて前記メモリ消費量積算値を更新するステップと、
前記予想積算値が前記制限値を超えた場合は、エラーを発生するステップと、
を有することを特徴とするメモリ管理方法。
A memory management method for managing memory used by a bundle operating on a software platform,
By computer,
Creating a group in the memory management unit and setting a limit value for the amount of memory available for each group;
When installing the bundle, setting the group on the class loader object of the bundle;
When the class loader object of the bundle or the software platform requests a memory, the caller of the bundle or the software platform that requested the memory is traced, and the bundle that is the first caller or the group to which the software platform belongs is requested. A step of selecting the memory amount as a count destination;
Comparing a predicted integrated value obtained by adding the requested memory amount to a memory consumption integrated value that is a total value of memory already allocated to the group selected in the selecting step and a limit value set for the group; ,
When the predicted integrated value is less than or equal to the limit value, the memory of the required memory amount is allocated from the heap area, and the memory consumption integrated value is calculated by adding the required memory amount to the memory consumption integrated value of the group. A step to update,
If the expected integrated value exceeds the limit value, generating an error;
A memory management method.
ソフトウェアプラットフォーム上で動作するバンドルが利用するメモリを管理するメモリ管理方法であって、
コンピュータによる、
メモリの管理単位でグループを作成し、グループ毎に利用できるメモリ量の制限値を設定するステップと、
前記バンドルをインストールする際に、当該バンドルのクラスローダオブジェクトに前記グループを設定するステップと、
前記バンドルあるいは前記ソフトウェアプラットフォームのクラスローダオブジェクトがメモリを要求したときに、メモリを要求した前記バンドルあるいは前記ソフトウェアプラットフォームの呼び出し元を辿り、前記ソフトウェアプラットフォームに呼び出されたバンドルが属するグループを要求メモリ量のカウント先として選択するステップと、
前記選択するステップで選択したグループにすでに割り当てられたメモリの合計値であるメモリ消費量積算値に前記要求メモリ量を加えた予想積算値と当該グループに設定された制限値とを比較するステップと、
前記予想積算値が前記制限値以下の場合は、ヒープ領域から前記要求メモリ量のメモリを割り当てるとともに、当該グループの前記メモリ消費量積算値に前記要求メモリ量を加えて前記メモリ消費量積算値を更新するステップと、
前記予想積算値が前記制限値を超えた場合は、エラーを発生するステップと、
を有することを特徴とするメモリ管理方法。
A memory management method for managing memory used by a bundle operating on a software platform,
By computer,
Creating a group in the memory management unit and setting a limit value for the amount of memory available for each group;
When installing the bundle, setting the group on the class loader object of the bundle;
When the class loader object of the bundle or the software platform requests the memory, the call source of the bundle or the software platform that requested the memory is traced, and the group to which the bundle called by the software platform belongs is determined as the required memory amount. A step to select as a count destination;
Comparing a predicted integrated value obtained by adding the requested memory amount to a memory consumption integrated value that is a total value of memory already allocated to the group selected in the selecting step and a limit value set for the group; ,
When the predicted integrated value is less than or equal to the limit value, the memory of the required memory amount is allocated from the heap area, and the memory consumption integrated value is calculated by adding the required memory amount to the memory consumption integrated value of the group. A step to update,
If the expected integrated value exceeds the limit value, generating an error;
A memory management method.
ソフトウェアプラットフォーム上で動作するバンドルが利用するメモリを管理するメモリ管理方法であって、
コンピュータによる、
メモリの管理単位でグループを作成し、グループ毎に利用できるメモリ量の制限値を設定するステップと、
前記バンドルをインストールする際に、当該バンドルのクラスローダオブジェクトに前記グループを設定するステップと、
前記バンドルに機能提供フラグあるいは機能利用フラグを設定するステップと、
前記バンドルあるいは前記ソフトウェアプラットフォームのクラスローダオブジェクトがメモリを要求したときに、メモリを要求した前記バンドルあるいは前記ソフトウェアプラットフォームの呼び出し元を辿り、前記ソフトウェアプラットフォームに呼び出されたバンドルが属するグループ、又は、機能利用フラグが設定されたバンドルが属するグループを要求メモリ量のカウント先として選択するステップと、
前記選択するステップで選択したグループにすでに割り当てられたメモリの合計値であるメモリ消費量積算値に前記要求メモリ量を加えた予想積算値と当該グループに設定された制限値とを比較するステップと、
前記予想積算値が前記制限値以下の場合は、ヒープ領域から前記要求メモリ量のメモリを割り当てるとともに、当該グループの前記メモリ消費量積算値に前記要求メモリ量を加えて前記メモリ消費量積算値を更新するステップと、
前記予想積算値が前記制限値を超えた場合は、エラーを発生するステップと、
を有することを特徴とするメモリ管理方法。
A memory management method for managing memory used by a bundle operating on a software platform,
By computer,
Creating a group in the memory management unit and setting a limit value for the amount of memory available for each group;
When installing the bundle, setting the group on the class loader object of the bundle;
Setting a function provision flag or a function use flag in the bundle;
When the class loader object of the bundle or the software platform requests a memory, the caller of the bundle or the software platform that requested the memory is traced, and the group to which the bundle called by the software platform belongs, or function use Selecting the group to which the bundle with the flag set belongs as a counting destination of the requested memory amount;
Comparing a predicted integrated value obtained by adding the requested memory amount to a memory consumption integrated value that is a total value of memory already allocated to the group selected in the selecting step and a limit value set for the group; ,
When the predicted integrated value is less than or equal to the limit value, the memory of the required memory amount is allocated from the heap area, and the memory consumption integrated value is calculated by adding the required memory amount to the memory consumption integrated value of the group. A step to update,
If the expected integrated value exceeds the limit value, generating an error;
A memory management method.
ソフトウェアプラットフォーム上で動作するバンドルが利用するメモリを管理するメモリ管理方法であって、A memory management method for managing memory used by a bundle operating on a software platform,
コンピュータによる、By computer,
メモリの管理単位でグループを作成し、グループ毎に利用できるメモリ量の制限値を設定するステップと、Creating a group in the memory management unit and setting a limit value for the amount of memory available for each group;
前記バンドルをインストールする際に、当該バンドルのクラスローダオブジェクトに前記グループを設定するステップと、When installing the bundle, setting the group on the class loader object of the bundle;
前記バンドルあるいは前記ソフトウェアプラットフォームがスレッドを立てるときに、当該スレッドを立てる前記バンドルあるいは前記ソフトウェアプラットフォームの属するグループを当該スレッドに設定するステップと、When the bundle or the software platform sets up a thread, setting the group to which the bundle or the software platform that sets up the thread belongs to the thread;
前記バンドルあるいは前記ソフトウェアプラットフォームのクラスローダオブジェクトがメモリを要求したときに、メモリを要求した前記バンドルあるいは前記ソフトウェアプラットフォームが属するスレッドに設定されたグループを要求メモリ量のカウント先として選択するステップと、When a class loader object of the bundle or the software platform requests memory, a group set in a thread to which the bundle or the software platform that requested the memory belongs is selected as a count destination of the requested memory amount;
前記選択するステップで選択したグループにすでに割り当てられたメモリの合計値であるメモリ消費量積算値に前記要求メモリ量を加えた予想積算値と当該グループに設定された制限値とを比較するステップと、Comparing a predicted integrated value obtained by adding the requested memory amount to a memory consumption integrated value that is a total value of memory already allocated to the group selected in the selecting step and a limit value set for the group; ,
前記予想積算値が前記制限値以下の場合は、ヒープ領域から前記要求メモリ量のメモリを割り当てるとともに、当該グループの前記メモリ消費量積算値に前記要求メモリ量を加えて前記メモリ消費量積算値を更新するステップと、When the predicted integrated value is less than or equal to the limit value, the memory of the required memory amount is allocated from the heap area, and the memory consumption integrated value is calculated by adding the required memory amount to the memory consumption integrated value of the group. A step to update,
前記予想積算値が前記制限値を超えた場合は、エラーを発生するステップと、If the expected integrated value exceeds the limit value, generating an error;
を有することを特徴とするメモリ管理方法。A memory management method.
メモリが要求されて生成されたオブジェクトに、当該メモリの消費量のカウント先として選択されたグループを識別するグループIDを付与するステップと、
指定されたグループIDが付与された前記オブジェクトのサイズを合計し、当該グループIDが示すグループのメモリ消費量を求めるステップと、
を有することを特徴とする請求項6乃至10のいずれかに記載のメモリ管理方法。
Assigning a group ID for identifying a group selected as a counting destination of consumption of the memory to an object generated when memory is requested;
Totaling the sizes of the objects to which the specified group ID is assigned, and determining the memory consumption of the group indicated by the group ID;
The memory management method according to claim 6, further comprising :
請求項6乃至11のいずれかに記載の各ステップをコンピュータに実行させることを特徴とするメモリ管理プログラム。 12. A memory management program for causing a computer to execute each step according to claim 6 .
JP2012040126A 2012-02-27 2012-02-27 Memory management device, memory management method, and memory management program Expired - Fee Related JP5357989B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2012040126A JP5357989B2 (en) 2012-02-27 2012-02-27 Memory management device, memory management method, and memory management program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2012040126A JP5357989B2 (en) 2012-02-27 2012-02-27 Memory management device, memory management method, and memory management program

Publications (2)

Publication Number Publication Date
JP2013175107A JP2013175107A (en) 2013-09-05
JP5357989B2 true JP5357989B2 (en) 2013-12-04

Family

ID=49267943

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2012040126A Expired - Fee Related JP5357989B2 (en) 2012-02-27 2012-02-27 Memory management device, memory management method, and memory management program

Country Status (1)

Country Link
JP (1) JP5357989B2 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107220077B (en) * 2016-10-20 2019-03-19 华为技术有限公司 Using the management-control method and management and control devices of starting

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2003076562A (en) * 2001-09-06 2003-03-14 Nippon Telegr & Teleph Corp <Ntt> Method, device for quantitatively controlling memory, computer program and recording medium
JP4215037B2 (en) * 2004-12-27 2009-01-28 セイコーエプソン株式会社 Resource management system, printer, printer network card, resource management program, and resource management method
JP2008015954A (en) * 2006-07-10 2008-01-24 Hitachi Ltd Gateway unit and system
JP2009134379A (en) * 2007-11-29 2009-06-18 Hitachi Ltd Memory management method
JP5157537B2 (en) * 2008-03-06 2013-03-06 日本電気株式会社 MEMORY MANAGEMENT DEVICE, SYSTEM, METHOD, AND PROGRAM
JP5684633B2 (en) * 2011-04-05 2015-03-18 日本電信電話株式会社 Memory management device, memory management method, and memory management program

Also Published As

Publication number Publication date
JP2013175107A (en) 2013-09-05

Similar Documents

Publication Publication Date Title
US8966464B1 (en) Isolating tenants executing in multi-tenant software containers
US11842217B1 (en) Isolating tenants executing in multi-tenant software containers
US10565104B2 (en) System and method to manage and share managed runtime memory for JAVA virtual machine
US9471353B1 (en) Isolating tenants executing in multi-tenant software containers
US10193977B2 (en) System, device and process for dynamic tenant structure adjustment in a distributed resource management system
US9397953B2 (en) Operation managing method for computer system, computer system and computer-readable storage medium having program thereon
US9754122B1 (en) Isolating tenants executing in multi-tenant software containers
US7840967B1 (en) Sharing data among isolated applications
JPWO2010116676A1 (en) Service providing apparatus, service providing system, data processing method of service providing apparatus, and computer program
TW201301029A (en) Memory manager with enhanced application metadata
US10102047B2 (en) In-memory data analytic system that provides an integrated tracking mechanism for explicit memory resources
JP2009524856A (en) Qualitatively annotated code
US8701095B2 (en) Add/remove memory pressure per object
US8615743B2 (en) Adaptive compiled code
JP6293683B2 (en) Computer system and coping method for performance failure of computer system
JP2005338985A (en) Method and system for managing storage area
JP5315128B2 (en) Process request destination management apparatus, process request destination management program, and process request destination management method
JP5684633B2 (en) Memory management device, memory management method, and memory management program
JP4862056B2 (en) Virtual machine management mechanism and CPU time allocation control method in virtual machine system
JP5357989B2 (en) Memory management device, memory management method, and memory management program
JP2015022385A (en) Virtual system and method for controlling virtual system
JP2016051395A (en) Image forming apparatus and resource management method
JP2012181673A (en) Resource allocation device, resource allocation method, and program
JP6051733B2 (en) Control system, control method, and control program
Richardson et al. RT-OSGi: Integrating the OSGi framework with the real-time specification for java

Legal Events

Date Code Title Description
A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20130611

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20130805

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

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20130830

R150 Certificate of patent or registration of utility model

Ref document number: 5357989

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

Free format text: JAPANESE INTERMEDIATE CODE: R150

S531 Written request for registration of change of domicile

Free format text: JAPANESE INTERMEDIATE CODE: R313531

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

LAPS Cancellation because of no payment of annual fees