WO2012006920A1 - 一种自适应回收垃圾对象的系统及方法 - Google Patents

一种自适应回收垃圾对象的系统及方法 Download PDF

Info

Publication number
WO2012006920A1
WO2012006920A1 PCT/CN2011/075951 CN2011075951W WO2012006920A1 WO 2012006920 A1 WO2012006920 A1 WO 2012006920A1 CN 2011075951 W CN2011075951 W CN 2011075951W WO 2012006920 A1 WO2012006920 A1 WO 2012006920A1
Authority
WO
WIPO (PCT)
Prior art keywords
garbage
garbage object
space
select
largest
Prior art date
Application number
PCT/CN2011/075951
Other languages
English (en)
French (fr)
Inventor
王文杰
周兴俊
陆刚
Original Assignee
中兴通讯股份有限公司
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 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2012006920A1 publication Critical patent/WO2012006920A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0253Garbage collection, i.e. reclamation of unreferenced memory

Definitions

  • the present invention relates to the field of JAVA virtual machines, and in particular, to a system and method for adaptively recycling garbage objects.
  • JAVA is currently the most widely used programming language. JAVA is popular among programmers because of its cross-platform nature. JAVA programs are widely used in servers, PCs, mobile terminals, and embedded consumer electronics. , smart cards and other areas, and is expanding to a wider range of areas.
  • JAVA is evolved from the traditional object-oriented language C++, running on the JAVA virtual machine, and the Java virtual machine manages resources and shields platform dependencies. Controlling and releasing the memory is a complicated task. In order to free the programmer from this work, the JAVA virtual machine has established a garbage collection mechanism.
  • the current garbage collection scheduling algorithms are:
  • garbage collection algorithms use the method of scheduling all the recycling to perform garbage collection.
  • the garbage collection algorithm which involves memory defragmentation, is a waste of CPU resources.
  • improve the performance of the JAVA virtual machine improve the performance of the JAVA virtual machine.
  • the invention provides a system and a method for adaptively recycling garbage objects. When the garbage objects are released, all the space occupied by the garbage objects is released, and waste of the memory space is avoided.
  • the invention provides a method for adaptively recycling garbage objects, comprising:
  • the garbage object When the garbage object is released during system operation, the heap space and the heap space of the garbage object are simultaneously released.
  • the garbage object is a JAVA garbage object.
  • the method further includes: selecting a garbage object to be released. When selecting, first selecting a garbage object with the largest occupied space to release, and if the memory space after the release still cannot meet the current system running requirement, further selecting the remaining garbage object to occupy the largest space. The garbage object is released until the released space meets the needs of the current system.
  • the method further includes: after selecting the garbage object to be released, determining whether to recycle the garbage object according to the current system running CPU resource usage status and the algorithm complexity of recovering the garbage, and determining whether to recycle if the current CPU resource is sufficient to release the garbage object.
  • the garbage object otherwise the garbage object is not recycled, and the largest garbage object occupying the space in the remaining garbage objects is selected for release.
  • the steps to select the garbage object that takes up the most space include:
  • the method further includes: during system operation, the JAVA virtual machine traverses all objects in the heap space, sets an object with a reference number of 0 as a garbage object, and calculates a complex granularity for recycling the garbage object; the traversing object is timing Traversing when traversing, or when garbage collection is required.
  • the present invention also provides a system for adaptively recycling garbage objects, including a release module; wherein: the release module is configured to: simultaneously release the garbage space and the outer space of the garbage object when the garbage object is released.
  • the garbage object is a JAVA garbage object.
  • the system also includes a selection module,
  • the selection module is configured to: select the released garbage object, and when selecting the released garbage object, first select the garbage object with the largest occupied space to release, and if the memory space after the release still cannot meet the current system operation requirement, further select the remaining garbage.
  • the garbage object with the largest space in the object is released until the released space meets the needs of the current system operation.
  • the system also includes a determination module, wherein:
  • the selection module is further configured to: send the selected garbage object to the determining module, and select the garbage object with the largest occupied space from the remaining garbage objects when the determining module determines that the selected garbage object is not recycled;
  • the determining module is configured to: determine whether to recycle the selected garbage object according to the current system running CPU resource usage status and the algorithm complexity of recovering the garbage, and determine to recycle the garbage object if the current CPU resource is sufficient to release the selected garbage object. Otherwise, the garbage object is not recycled; when it is determined that the garbage object is not recycled, the selection module is notified to re-select the garbage object for recycling.
  • the selection module is configured to select the garbage object that occupies the largest space in the following manner:
  • the system also includes a setting module
  • the setting module is configured to: traverse all objects in the heap space during system operation, set an object with a reference number of 0 as a garbage object, and calculate a complex granularity of the garbage object; wherein the setting module traverses Objects are traversed at regular intervals, or when garbage objects need to be recycled.
  • the present invention provides a system and method for adaptively recycling garbage objects, which avoids waste of memory space by releasing all space occupied by garbage objects; further, it can be released according to current system operation requirements, instead of Free all garbage objects at once, improving the utilization of CPU resources and the performance of the JAVA virtual machine.
  • the invention is particularly applicable to JAVA virtual machines on embedded systems with low CPU performance and small memory capacity.
  • Figure 1 is a schematic structural view of the system of the present invention
  • the present invention provides a system and method for adaptively recycling garbage objects.
  • the JAVA garbage object is released during system operation, the heap space and the heap space of the object are simultaneously released.
  • the embodiment provides a system for adaptively recycling garbage objects, as shown in FIG. 1 , including a release module, a determination module, a selection module, and a setting module;
  • the selection module is set to: select the released garbage object
  • the module When selecting the garbage object to be released by the module, first select the garbage object with the largest space to release. If the memory space still cannot meet the current system running requirements after release, further select the largest garbage object in the remaining garbage object to release, until The released space meets the needs of the current system operation.
  • the selection module is further configured to: send the selected garbage object to the judgment module, and when When the garbage object selected by the block decision cannot be recycled, the garbage object having the largest occupied space is selected from the remaining garbage objects;
  • the judging module is configured to: determine whether to reclaim the selected garbage object according to the current system running CPU resource usage status and the algorithm complexity of reclaiming the garbage, and determine that the garbage object can be reclaimed if the current CPU resource is sufficient to release the garbage object, otherwise Recycling the garbage object; when it is determined that the garbage object cannot be recycled, the selection module is notified to re-select the garbage object for recycling.
  • the release module is set to: When the JAVA garbage object is released, the heap space and the heap space of the garbage object are simultaneously released. Selecting a module to select the garbage object that has the largest space is:
  • the setting module is set to: traverse all objects in the heap space during system operation, set the object with reference number 0 as garbage object, and calculate the complex granularity of recycling the garbage object;
  • Setting the module traversal object can be a time traversal, or it can be traversed when garbage object recycling is required.
  • the embodiment provides a method for adaptively recycling garbage objects.
  • the JAVA virtual machine creates an object information list, records the size of all objects during the running of the JAVA program, creates the in-heap and extra-heap space of the object application, and marks whether the object is For garbage, the queues are sorted by the amount of free space.
  • Step SI When the space occupied by the object of the JAVA program needs to be released, the JAVA virtual machine selects the recycling object according to the preset recycling object manner;
  • the preset method of recycling objects can be, but is not limited to, the following:
  • a process other than a virtual machine triggers garbage collection.
  • the process related to the virtual machine (such as the graphics engine, media player module, etc.), when the memory is detected, when the memory is insufficient, the JAVA virtual machine is notified to perform garbage collection, and the JAVA virtual machine receives the recycling notification, and uses the occupied space.
  • the method of recycling the garbage in a large priority is to recycle the garbage object, that is, to select the garbage object that occupies the largest space outside the heap as the object of recycling.
  • Memory consumption here refers to the sum of the heap and the heap space occupied.
  • JAVA program When a JAVA program creates a new object, it checks whether there is enough memory for allocation. If it is insufficient, it uses the way of occupying the heap space to reclaim garbage. That is, it selects the garbage object that occupies the largest heap space as the object of recycling.
  • Step S2 The JAVA virtual machine determines whether to recycle the garbage object according to the current system running CPU resource usage status and the algorithm complexity of recovering the garbage, if yes, step S3 is performed; otherwise, step S6 is performed;
  • the calculation method of complex granularity can refer to the prior art.
  • Determining whether to recycle the garbage object means that if the current CPU resource is sufficient to release the garbage object, it is determined that the garbage object can be recycled, otherwise the garbage object cannot be recycled.
  • the JAVA virtual machine traverses all the objects in the heap space, and the reference count of the query object.
  • the object is considered to be a garbage object, and the object queue is marked as a garbage object, and Calculate the complex granularity of reclaiming the garbage object (that is, the CPU resources that need to be consumed to reclaim the garbage object).
  • the traversal object can be a timed traversal, or it can be traversed when a garbage object needs to be recycled. Step S3: Recycling the garbage object, that is, releasing the occupied space inside and outside the heap;
  • Step S4 It is determined whether the released space has met the current running requirement, and if yes, step S5 is performed, otherwise, step S1 is returned.
  • Step S5 Clean up the memory fragmentation.
  • Step S6 Select the next garbage object, and then return to step S2.
  • the present invention provides a system and method for adaptively recycling garbage objects, which avoids waste of memory space by releasing all space occupied by garbage objects; further, it can be released according to current system operation requirements, instead of It releases the garbage object at one time, improves the utilization of CPU resources and the performance of the JAVA virtual machine, so it has strong industrial applicability.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System (AREA)

Abstract

本发明提供一种自适应回收垃圾对象的系统及方法,该方法包括,当系统运行期间,释放JAVA垃圾对象时,同时释放所述对象的堆内空间及堆外空间。采用本发明的技术方案,通过释放垃圾对象占用的所有空间,避免了内存空间的浪费;再者,可根据当前系统运行需要进行释放,而不是一次释放所有垃圾对象,提高了CPU资源的利用率以及JAVA虚拟机的性能。

Description

一种自适应回收垃圾对象的系统及方法
技术领域
本发明涉及 JAVA虚拟机领域, 尤其涉及一种自适应回收垃圾对象的系 统及方法。
背景技术
JAVA是目前使用最广泛的程序设计语言, JAVA由于其跨平台性,有很 强的可移植性, 得到广大程序员的青睐, JAVA程序广泛应用于服务器、 PC、 移动终端、 嵌入式消费电子产品、 智能卡等领域, 并正在向更广泛的领域扩 展。
JAVA是由传统的面向对象语言 C++演进过来, 运行于 JAVA虚拟机之 上, 由 JAVA虚拟机管理资源和屏蔽平台相关性。 对内存的控制和及时释放 是一项很复杂的工作, 为了将程序员从这项工作中解放出来, JAVA虚拟机 建立了垃圾回收机制。
现用的垃圾回收调度算法有:
1 系统定时遍历堆中所有对象, 判断对象为垃圾就进行回收。 这种垃圾 回收调度方法不及时, 可能在实例化一个对象时, 堆空间不够导致为对象分 配空间失败, 还可能会在 CPU繁忙时, 到达定时回收时间, 还要回收所有垃 圾。 导致系统更繁忙, 程序运行不畅。
2 在新创建一个对象时, 判断堆空间是否足够, 如果不够, 马上调度垃 圾回收算法, 回收所有垃圾。 这种调度方式只对 JAVA虚拟机堆空间的内存 进行管理, 不能限制分配在堆外空间的内存。 釆用这种调度方法会出现堆空 间足够, 垃圾对象占用较大堆外空间, 造成内存资源的浪费。 甚至因为内存 不够而出现导致系统运行不畅。
3 JAVA程序开发人员主动调用 JAVA虚拟机提供的垃圾回收接口函数 调度垃圾回收。 这种办法又恢复到传统编程方式的内存管理方法。 其缺点是 要预先确定占用的内存空间是否应该被回收, 程序员不仅要考虑如何实现算 法满足应用, 还要花费很多精力考虑合理利用内存, 避免内存泄露。
另外, 现有的垃圾回收算法均釆用一次调度全部回收的方式进行垃圾回 收。垃圾回收算法, 涉及到内存碎片整理等,是一项很浪费 CPU资源的工作。 为了消除传统垃圾回收算法的以上缺点, 提高 JAVA虚拟机性能。
发明内容
本发明提供一种自适应回收垃圾对象的系统及方法, 释放垃圾对象时, 释放垃圾对象占用的所有空间, 避免了内存空间的浪费。 本发明提供了一种自适应回收垃圾对象的方法, 包括:
当系统运行期间, 释放垃圾对象时, 同时释放所述垃圾对象的堆内空间 及堆外空间。 其中, 所述垃圾对象为 JAVA垃圾对象。
所述方法还包括: 选择要释放的垃圾对象, 选择时, 先选择占用空间最 大的垃圾对象进行释放, 若释放后内存空间仍不能满足当前系统运行需要, 则进一步选择剩余垃圾对象中占用空间最大的垃圾对象进行释放, 直到释放 的空间满足当前系统运行需要。
所述方法还包括: 选择要释放的垃圾对象后, 根据当前系统运行 CPU资 源使用状况和回收该垃圾的算法复杂度判断是否回收该垃圾对象, 若当前 CPU的资源足够释放该垃圾对象时判定回收该垃圾对象, 否则不回收该垃圾 对象, 选择其余垃圾对象中占用空间最大垃圾对象的进行释放。
其中: 选择占用空间最大的垃圾对象的步骤包括:
( 1 )当虚拟机之外的进程触发垃圾对象回收时, 选择占用堆外空间最大 的垃圾对象;
( 2 )当检测到内存占用量超过系统稳定阀值时释放垃圾对象时, 选择占 用的堆内及堆外空间之和最大的垃圾对象;
( 3 )当创建新的 JAVA对象且因内存不够需要释放垃圾对象时, 选择占 用堆内空间最大的垃圾对象。 所述方法还包括: 系统运行期间, JAVA虚拟机遍历堆空间中的所有对 象, 将引用数为 0的对象设为垃圾对象, 并计算回收所述垃圾对象的复杂粒 度; 所述遍历对象是定时遍历, 或是需要进行垃圾对象回收时进行遍历。
本发明还提供了一种自适应回收垃圾对象的系统, 包括释放模块; 其中: 所述释放模块设置成: 释放垃圾对象时, 同时释放所述垃圾对象的堆内 空间及堆外空间。
其中, 所述垃圾对象为 JAVA垃圾对象。
所述系统还包括选择模块,
所述选择模块设置成: 选择释放的垃圾对象, 在选择释放的垃圾对象时, 先选择占用空间最大的垃圾对象进行释放, 若释放后内存空间仍不能满足当 前系统运行需要, 则进一步选择剩余垃圾对象中占用空间最大的垃圾对象进 行释放, 直到释放的空间满足当前系统运行需要。
所述系统还包括判断模块, 其中:
所述选择模块还设置成: 将选择的垃圾对象发送至所述判断模块, 以及 当所述判断模块判定选择的垃圾对象不回收时从剩余垃圾对象中选择占用空 间最大的垃圾对象;
所述判断模块设置成:根据当前系统运行 CPU资源使用状况和回收该垃 圾的算法复杂度判断是否回收所选择的垃圾对象,若当前 CPU的资源足够释 放所选择的垃圾对象时判定回收该垃圾对象, 否则不回收该垃圾对象; 当判 定不回收该垃圾对象时通知所述选择模块重新选择垃圾对象进行回收。
其中,所述选择模块设置成按照以下方式选择占用空间最大的垃圾对象:
( 1 )当虚拟机之外的进程触发垃圾对象回收时, 选择占用堆外空间最大 的垃圾对象;
( 2 )当检测到内存占用量超过系统稳定阀值时释放垃圾对象时, 选择占 用的堆内及堆外空间之和最大的垃圾对象;
( 3 )当创建新的 JAVA对象且因内存不够需要释放垃圾对象时, 选择占 用堆内空间最大的垃圾对象。 所述系统还包括设置模块;
所述设置模块设置成: 在系统运行期间, 遍历堆空间中的所有对象, 将 引用数为 0的对象设为垃圾对象, 以及计算回收所述垃圾对象的复杂粒度; 其中, 所述设置模块遍历对象是定时遍历, 或是需要进行垃圾对象回收 时进行遍历。
综上所述, 本发明提供一种自适应回收垃圾对象的系统及方法, 通过释 放垃圾对象占用的所有空间, 避免了内存空间的浪费; 再者, 可根据当前系 统运行需要进行释放, 而不是一次释放所有垃圾对象, 提高了 CPU资源的利 用率以及 JAVA虚拟机的性能。
本发明尤其适用于 CPU性能低、 内存容量较小的嵌入式系统上的 JAVA 虚拟机。 附图概述
图 1是本发明系统结构示意图;
图 2是本发明方法流程图。
本发明的较佳实施方式
本发明提供一种自适应回收垃圾对象的系统及方法, 当系统运行期间, 释放 JAVA垃圾对象时, 同时释放该对象的堆内空间及堆外空间。
本实施例提供一种自适应回收垃圾对象的系统, 如图 1所示, 包括释放 模块、 判断模块、 选择模块及设置模块;
选择模块设置成: 选择释放的垃圾对象;
选择模块选择释放的垃圾对象时, 先选择占用空间最大的垃圾对象进行 释放, 若释放后内存空间仍不能满足当前系统运行需要, 则进一步选择剩余 垃圾对象中占用空间最大垃圾对象的进行释放, 直到释放的空间满足当前系 统运行需要。
选择模块还设置成: 将选择的垃圾对象发送至判断模块, 以及当判断模 块判定选择的垃圾对象不可以回收时从剩余垃圾对象中选择占用空间最大的 垃圾对象;
判断模块设置成:根据当前系统运行 CPU资源使用状况和回收该垃圾的 算法复杂度判断是否回收选择的垃圾对象,若当前 CPU的资源足够释放该垃 圾对象时判定可以回收该垃圾对象, 否则不可以回收该垃圾对象; 当判定不 可以回收该垃圾对象时通知选择模块重新选择垃圾对象进行回收。
释放模块设置成: 释放 JAVA垃圾对象时, 同时释放该垃圾对象的堆内 空间及堆外空间。 选择模块选择占用空间最大的垃圾对象是指:
( 1 )当虚拟机之外的进程触发垃圾对象回收时, 选择占用堆外空间最大 的垃圾对象;
( 2 )当检测到内存占用量超过系统稳定阀值时释放垃圾对象时, 选择占 用的堆内及堆外空间之和最大的垃圾对象;
( 3 )当创建新的 JAVA对象且因内存不够需要释放垃圾对象时, 选择占 用堆内空间最大的垃圾对象。
设置模块设置成: 系统运行期间, 遍历堆空间中的所有对象, 将引用数 为 0的对象设为垃圾对象, 以及计算回收该垃圾对象的复杂粒度;
设置模块遍历对象可以是定时遍历, 也可以是需要进行垃圾对象回收时 进行遍历。
本实施例提供一种自适应回收垃圾对象的方法, JAVA虚拟机创建一个 对象信息列表, 记录 JAVA程序运行期间所有对象大小的大小、 创建该对象 申请的堆内及堆外空间, 以及标记对象是否为垃圾, 队列按照可释放空间大 小排序。
当系统运行期间, 释放 JAVA垃圾对象时, 同时释放该对象的堆内空间 及堆外空间。 如图 2所示, 包括以下步骤: 步骤 SI : 当需要释放 JAVA程序的对象占用的空间时, JAVA虚拟机按 照预设的回收对象方式选择回收对象;
预设的回收对象方式可以但不限于以下方式:
( 1 )虚拟机之外的进程触发垃圾对象回收。
和虚拟机相关的进程(如图形引擎、 媒体播放模块等), 在申请内存时, 探测到内存不足时, 通知 JAVA虚拟机进行垃圾回收, JAVA虚拟机接收到 回收通知, 釆用占用堆外空间大优先回收的方式来回收垃圾对象, 即选择占 用堆外空间最大的垃圾对象作为回收对象。
( 2 )定时检测系统, 回收垃圾对象。
定期查询当前内存使用状态, 如果内存占用量超过系统稳定阀值, 则查 找当前可供回收的垃圾对象。 釆用消耗内存资源多优先回收的方式来回收垃 圾, 即选择占用内存最大的垃圾对象作为回收对象。
此处消耗内存指占用的堆内及堆外空间之和。
( 3 )堆空间不够时触发垃圾对象回收。
JAVA程序创建新的对象时, 检查是否有足够的内存供分配, 如果不足, 釆用占据堆内空间多优先回收的方式来回收垃圾, 即选择占用堆内空间最大 的垃圾对象作为回收对象。
步骤 S2: JAVA虚拟机根据当前系统运行 CPU资源使用状况和回收该垃 圾的算法复杂度判断是否回收该垃圾对象, 是则执行步骤 S3 , 否则执行步骤 S6;
复杂粒度的计算方法可参照现有技术。
判断是否回收该垃圾对象是指,若当前 CPU的资源足够释放该垃圾对象 时判定可以回收该垃圾对象, 否则不可以回收该垃圾对象。
JAVA程序运行期间, JAVA虚拟机遍历堆空间中的所有对象, 查询对象 的引用计数, 当某对象的引用数为 0时, 便认为该对象是垃圾对象, 将对象 队列中标记为垃圾对象, 并计算回收该垃圾对象的复杂粒度(即回收该垃圾 对象需要消耗的 CPU资源) 。 遍历对象可以是定时遍历, 也可以是需要回收垃圾对象时进行遍历。 步骤 S3: 回收该垃圾对象, 即释放其占用的堆内及堆外空间;
步骤 S4: 判断释放的空间是否已满足当前运行需要, 是则执行步骤 S5, 否则返回步骤 Sl。
步骤 S5: 整理内存碎片。
步骤 S6: 选择下一个垃圾对象, 然后返回步骤 S2。
本领域普通技术人员可以理解上述方法中的全部或部分步骤可通过程序 来指令相关硬件完成, 所述程序可以存储于计算机可读存储介质中, 如只读 存储器、 磁盘或光盘等。 可选地, 上述实施例的全部或部分步骤也可以使用 一个或多个集成电路来实现。 相应地, 上述实施例中的各模块 /单元可以釆用 硬件的形式实现, 也可以釆用软件功能模块的形式实现。 本发明不限制于任 何特定形式的硬件和软件的结合。
以上所述仅为本发明的优选实施例而已, 并不用于限制本发明, 对于本 领域的技术人员来说, 本发明可以有各种更改和变化。 凡在本发明的精神和 原则之内, 所作的任何修改、 等同替换、 改进等, 均应包含在本发明的保护 范围之内。
工业实用性
综上所述, 本发明提供一种自适应回收垃圾对象的系统及方法, 通过释 放垃圾对象占用的所有空间, 避免了内存空间的浪费; 再者, 可根据当前系 统运行需要进行释放, 而不是一次释放所有垃圾对象, 提高了 CPU资源的利 用率以及 JAVA虚拟机的性能, 因此具有极强的工业实用性。

Claims

权 利 要 求 书
1、 一种自适应回收垃圾对象的方法, 包括:
当系统运行期间, 释放垃圾对象时, 同时释放所述垃圾对象的堆内空间 及堆外空间。
2、 如权利要求 1所述的方法, 其中, 所述垃圾对象为 JAVA垃圾对象。
3、 如权利要求 2所述的方法, 所述方法还包括:
选择要释放的垃圾对象, 选择时, 先选择占用空间最大的垃圾对象进行 释放, 若释放后内存空间仍不能满足当前系统运行需要, 则进一步选择剩余 垃圾对象中占用空间最大的垃圾对象进行释放, 直到释放的空间满足当前系 统运行需要。
4、 如权利要求 3所述的方法, 所述方法还包括:
选择要释放的垃圾对象后,根据当前系统运行 CPU资源使用状况和回收 该垃圾的算法复杂度判断是否回收该垃圾对象,若当前 CPU的资源足够释放 该垃圾对象时判定回收该垃圾对象, 否则不回收该垃圾对象, 选择其余垃圾 对象中占用空间最大垃圾对象的进行释放。
5、 如权利要求 3或 4所述的方法, 其中: 选择占用空间最大的垃圾对象 的步骤包括:
( 1 )当虚拟机之外的进程触发垃圾对象回收时, 选择占用堆外空间最大 的垃圾对象;
( 2 )当检测到内存占用量超过系统稳定阀值时释放垃圾对象时, 选择占 用的堆内及堆外空间之和最大的垃圾对象;
( 3 )当创建新的 JAVA对象且因内存不够需要释放垃圾对象时, 选择占 用堆内空间最大的垃圾对象。
6、 如权利要求 2所述的方法, 所述方法还包括:
系统运行期间, JAVA虚拟机遍历堆空间中的所有对象, 将引用数为 0 的对象设为垃圾对象, 并计算回收所述垃圾对象的复杂粒度;
所述遍历对象是定时遍历, 或是需要进行垃圾对象回收时进行遍历。
7、 一种自适应回收垃圾对象的系统, 包括释放模块; 其中:
所述释放模块设置成: 释放垃圾对象时, 同时释放所述垃圾对象的堆内 空间及堆外空间。
8、 如权利要求 7所述的系统, 其中, 所述垃圾对象为 JAVA垃圾对象。
9、 如权利要求 8所述的系统, 所述系统还包括选择模块,
所述选择模块设置成: 选择释放的垃圾对象, 在选择释放的垃圾对象时, 先选择占用空间最大的垃圾对象进行释放, 若释放后内存空间仍不能满足当 前系统运行需要, 则进一步选择剩余垃圾对象中占用空间最大的垃圾对象进 行释放, 直到释放的空间满足当前系统运行需要。
10、 如权利要求 9所述的系统, 所述系统还包括判断模块, 其中: 所述选择模块还设置成: 将选择的垃圾对象发送至所述判断模块, 以及 当所述判断模块判定选择的垃圾对象不回收时从剩余垃圾对象中选择占用空 间最大的垃圾对象;
所述判断模块设置成:根据当前系统运行 CPU资源使用状况和回收该垃 圾的算法复杂度判断是否回收所选择的垃圾对象,若当前 CPU的资源足够释 放所选择的垃圾对象时判定回收该垃圾对象, 否则不回收该垃圾对象; 当判 定不回收该垃圾对象时通知所述选择模块重新选择垃圾对象进行回收。
11、 如权利要求 9或 10所述的系统, 其中, 所述选择模块设置成按照以 下方式选择占用空间最大的垃圾对象:
( 1 )当虚拟机之外的进程触发垃圾对象回收时, 选择占用堆外空间最大 的垃圾对象;
( 2 )当检测到内存占用量超过系统稳定阀值时释放垃圾对象时, 选择占 用的堆内及堆外空间之和最大的垃圾对象;
( 3 )当创建新的 JAVA对象且因内存不够需要释放垃圾对象时, 选择占 用堆内空间最大的垃圾对象。
12、 如权利要求 7所述的系统, 所述系统还包括设置模块;
所述设置模块设置成: 在系统运行期间, 遍历堆空间中的所有对象, 将 引用数为 0的对象设为垃圾对象, 以及计算回收所述垃圾对象的复杂粒度; 其中, 所述设置模块遍历对象是定时遍历, 或是需要进行垃圾对象回收时进 行遍历。
PCT/CN2011/075951 2010-07-14 2011-06-20 一种自适应回收垃圾对象的系统及方法 WO2012006920A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201010227644.6 2010-07-14
CN2010102276446A CN101894049A (zh) 2010-07-14 2010-07-14 一种自适应回收垃圾对象的系统及方法

Publications (1)

Publication Number Publication Date
WO2012006920A1 true WO2012006920A1 (zh) 2012-01-19

Family

ID=43103245

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2011/075951 WO2012006920A1 (zh) 2010-07-14 2011-06-20 一种自适应回收垃圾对象的系统及方法

Country Status (2)

Country Link
CN (1) CN101894049A (zh)
WO (1) WO2012006920A1 (zh)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101894049A (zh) * 2010-07-14 2010-11-24 中兴通讯股份有限公司 一种自适应回收垃圾对象的系统及方法
CN102270134B (zh) * 2011-08-09 2015-05-27 北京握奇数据系统有限公司 一种Java卡中垃圾回收的方法及装置
CN102609313B (zh) * 2012-01-13 2014-04-02 汉柏科技有限公司 多核系统资源延迟回收锁的实现方法及系统
CN103365703B (zh) * 2012-03-26 2016-09-21 宇龙计算机通信科技(深圳)有限公司 提高系统最大可回收内存的方法及其执行系统
CN106339183B (zh) * 2016-08-29 2020-02-11 东软集团股份有限公司 数据检索的方法及服务器
CN107766155A (zh) * 2017-10-23 2018-03-06 北京京东尚科信息技术有限公司 对象处理方法及系统
CN108255582B (zh) * 2018-01-16 2021-02-02 携程旅游信息技术(上海)有限公司 java虚拟机垃圾回收的方法、系统、设备及存储介质
CN112217940B (zh) * 2020-08-28 2021-12-24 波克科技股份有限公司 一种内存释放方法及相关装置

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1829977A (zh) * 2003-08-01 2006-09-06 英特尔公司 利用一个栈跟踪高速缓存器改善垃圾收集的性能的方法和装置
US20090070776A1 (en) * 2007-09-07 2009-03-12 Oracle International Corporation System and method to improve memory usage in virtual machines running as hypervisor guests
CN101493767A (zh) * 2009-01-20 2009-07-29 中国科学技术大学 一种即时编译器辅助的垃圾收集中显式释放对象的插桩方法
CN101894049A (zh) * 2010-07-14 2010-11-24 中兴通讯股份有限公司 一种自适应回收垃圾对象的系统及方法

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2005001695A1 (ja) * 2003-06-30 2005-01-06 Matsushita Electric Industrial Co., Ltd. ガーベジコレクションシステム
CN101727355B (zh) * 2008-10-31 2013-02-20 国际商业机器公司 用于内存访问事件的处理方法和系统

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1829977A (zh) * 2003-08-01 2006-09-06 英特尔公司 利用一个栈跟踪高速缓存器改善垃圾收集的性能的方法和装置
US20090070776A1 (en) * 2007-09-07 2009-03-12 Oracle International Corporation System and method to improve memory usage in virtual machines running as hypervisor guests
CN101493767A (zh) * 2009-01-20 2009-07-29 中国科学技术大学 一种即时编译器辅助的垃圾收集中显式释放对象的插桩方法
CN101894049A (zh) * 2010-07-14 2010-11-24 中兴通讯股份有限公司 一种自适应回收垃圾对象的系统及方法

Also Published As

Publication number Publication date
CN101894049A (zh) 2010-11-24

Similar Documents

Publication Publication Date Title
WO2012006920A1 (zh) 一种自适应回收垃圾对象的系统及方法
CN101452404B (zh) 一种嵌入式操作系统的任务调度装置及方法
CN111694633A (zh) 集群节点负载均衡方法、装置及计算机存储介质
CN102866918B (zh) 面向分布式编程框架的资源管理系统
CN103179048A (zh) 云数据中心的主机QoS策略变换方法及系统
US8352775B1 (en) State machine controlled dynamic distributed computing
CN101694631B (zh) 实时作业调度系统及方法
CN103365726A (zh) 一种面向gpu集群的资源管理方法和系统
CN102779075A (zh) 一种在多处理器核系统中进行调度的方法、装置及系统
CN106547612A (zh) 一种多任务处理方法及装置
CN111399986A (zh) Pod资源配额配置方法及装置
CN102473118A (zh) 信息处理系统
CN102027447A (zh) 调度器中的局部任务集合
WO2022143446A1 (zh) 内存释放方法及相关设备
CN100346307C (zh) Java操作系统中实时任务调度的实现方法
CN111258746B (zh) 资源分配方法和服务设备
JP2011028559A (ja) 中継プログラムおよび電子制御装置
WO2011027626A1 (ja) メモリ管理方法、計算機システム及びコンピュータ可読媒体
CN102411513B (zh) 一种工作于混合模式执行引擎中的垃圾收集方法
CN113032102A (zh) 资源重调度方法、装置、设备和介质
CN105808346A (zh) 一种任务调度方法与装置
CN108595259B (zh) 一种基于全局管理的内存池管理方法
CN105912383A (zh) 一种高可靠性的依赖任务调度与资源配置方法
CN103677959A (zh) 一种基于组播的虚拟机集群迁移方法及系统
EP4189542A1 (en) Sharing of compute resources between the virtualized radio access network (vran) and other workloads

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 11806262

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 11806262

Country of ref document: EP

Kind code of ref document: A1