Memory Management for Reference Cycle Reclamation

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Reference cycles in object-oriented programming languages lead to memory resource waste as memory occupied by objects in cycles cannot be reclaimed due to persistent reference counting values.

Innovation Solution

A memory management method that identifies and reclaims memory resources by obtaining and matching information about first and second reference cycles, ensuring objects within these cycles are not externally referenced, allowing for efficient memory recovery.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Extent of automation

If reference counting algorithm is used to manage memory, then automatic memory management is achieved, but memory resources occupied by objects in reference cycles cannot be reclaimed

Engineering Contradiction:
Improveautomatic memory managementVSAvoidmemory resource waste
Core Design Contradiction:
Extent of automationVSLoss of substance

Solution Approach 1:

The patent segments the memory management process into two distinct phases: reference counting for automatic detection of unreferenced objects, and cycle detection for identifying reference cycles. This segmentation allows the system to handle different memory scenarios with appropriate algorithms, resolving the contradiction by maintaining automatic management while enabling cycle reclamation.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent introduces an intermediary mechanism that bridges reference counting and cycle detection. When reference counting identifies objects with zero external references, the system activates cycle detection as an intermediary step to determine whether these objects form reference cycles before final reclamation. This intermediary approach enables automatic memory management to overcome its limitation with reference cycles.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Stability of the object's composition

If objects in reference cycles maintain reference counting values of at least 1, then cyclic reference structure is preserved, but memory resources cannot be reclaimed

Engineering Contradiction:
Improvecyclic reference structureVSAvoidmemory resource waste
Core Design Contradiction:
Stability of the object's compositionVSLoss of substance

Solution Approach 1:

The patent performs preliminary action by detecting reference cycles before final memory reclamation. The system identifies objects participating in reference cycles and temporarily marks them for special handling. This preliminary detection allows the system to preserve the cyclic structure during analysis while planning for subsequent reclamation, resolving the contradiction between structure preservation and memory recovery.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent inverts the traditional approach by not attempting to break reference cycles during normal operation, but rather detecting them first and then systematically reclaiming them as a separate operation. This inversion allows the cyclic structure to remain stable during program execution while enabling memory reclamation when the cycles are no longer needed, resolving the contradiction between structural stability and resource recovery.

Inventive Principle:
Principle #13The other way round (Inversion)

Data Source

PatentUS12159154B2Memory management method and apparatus
Publication Date: 2024.12.03 HUAWEI TECH CO LTD
  • US12159154B2 patent drawing
  • US12159154B2 patent drawing
  • US12159154B2 patent drawing

AI summary

The technology of this application relates to a memory management method and apparatus. When garbage collection is performed by using the method, stored information about a first reference cycle is first obtained, where the first reference cycle is a cyclic reference formed by a plurality of objects, and the information about the first reference cycle includes the plurality of objects in the first reference cycle and a reference relationship between the plurality of objects. The method further includes determining that a second reference cycle exists, where information about the second reference cycle matches the information about the first reference cycle, and the information about the second reference cycle includes a plurality of objects in the second reference cycle and a reference relationship between the plurality of objects. The method further includes reclaiming memory occupied by the plurality of objects in the second reference cycle.