Memory Management for Reference Cycle Reclamation
Find Innovative SolutionsGenerate 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
Engineering 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
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.
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.
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
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.
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.
Data Source
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.


